11import { defineConfig } from 'vite'
22import react from '@vitejs/plugin-react'
33import { VitePWA } from 'vite-plugin-pwa'
4- import { copyFileSync , mkdirSync , readdirSync } from 'fs'
5- import { join } from 'path'
6-
7- // Plugin to copy Stencil web component assets
8- const copyStencilAssets = ( ) => ( {
9- name : 'copy-stencil-assets' ,
10- closeBundle ( ) {
11- const src = 'node_modules/@sutton-signwriting/sgnw-components/dist/sgnw-components'
12- const dest = 'dist/assets/sgnw-components'
13-
14- mkdirSync ( dest , { recursive : true } )
15-
16- const files = readdirSync ( src )
17- files . forEach ( file => {
18- copyFileSync ( join ( src , file ) , join ( dest , file ) )
19- } )
20-
21- console . log ( '✓ Copied Stencil web component assets' )
22- }
23- } )
244
255// https://vite.dev/config/
266export default defineConfig ( {
277 base : '/signwriting-word-processor/' ,
288 plugins : [
299 react ( ) ,
30- copyStencilAssets ( ) ,
3110 VitePWA ( {
3211 registerType : 'autoUpdate' ,
3312 manifest : {
@@ -53,18 +32,5 @@ export default defineConfig({
5332 navigateFallback : null
5433 }
5534 } )
56- ] ,
57- build : {
58- commonjsOptions : {
59- include : [ / n o d e _ m o d u l e s / ]
60- } ,
61- rollupOptions : {
62- output : {
63- inlineDynamicImports : true
64- }
65- }
66- } ,
67- optimizeDeps : {
68- include : [ '@sutton-signwriting/sgnw-components' ]
69- }
35+ ]
7036} )
0 commit comments