@@ -7,68 +7,73 @@ import compression from "vite-plugin-compression";
77import viteImagemin from "vite-plugin-imagemin" ;
88import babelReactCompiler from "babel-plugin-react-compiler" ;
99
10- export default defineConfig ( {
11- base : "/sqlite-online/" ,
12- plugins : [
13- react ( {
14- babel : {
15- plugins : [ babelReactCompiler ]
16- }
17- } ) ,
18- tailwindcss ( ) ,
19- compression ( ) ,
20- viteImagemin ( {
21- gifsicle : {
22- optimizationLevel : 7 ,
23- interlaced : false
24- } ,
25- optipng : {
26- optimizationLevel : 7
27- } ,
28- mozjpeg : {
29- quality : 20
30- } ,
31- pngquant : {
32- quality : [ 0.8 , 0.9 ] ,
33- speed : 4
34- } ,
35- svgo : {
36- plugins : [
37- {
38- name : "removeViewBox"
39- } ,
40- {
41- name : "removeEmptyAttrs" ,
42- active : false
43- }
44- ]
45- }
46- } )
47- ] ,
48- build : {
49- rollupOptions : {
50- output : {
51- manualChunks ( id ) {
52- if ( id . includes ( "node_modules" ) ) {
53- return id
54- . toString ( )
55- . split ( "node_modules/" ) [ 1 ]
56- . split ( "/" ) [ 0 ]
57- . toString ( ) ;
10+ export default defineConfig ( ( { mode } ) => {
11+ const isPages = mode === 'pages' ;
12+ console . log ( 'Mode:' , mode ) ;
13+
14+ return {
15+ base : isPages ? '/sqlite-online/' : '/' ,
16+ plugins : [
17+ react ( {
18+ babel : {
19+ plugins : [ babelReactCompiler ]
20+ }
21+ } ) ,
22+ tailwindcss ( ) ,
23+ compression ( ) ,
24+ viteImagemin ( {
25+ gifsicle : {
26+ optimizationLevel : 7 ,
27+ interlaced : false
28+ } ,
29+ optipng : {
30+ optimizationLevel : 7
31+ } ,
32+ mozjpeg : {
33+ quality : 20
34+ } ,
35+ pngquant : {
36+ quality : [ 0.8 , 0.9 ] ,
37+ speed : 4
38+ } ,
39+ svgo : {
40+ plugins : [
41+ {
42+ name : "removeViewBox"
43+ } ,
44+ {
45+ name : "removeEmptyAttrs" ,
46+ active : false
47+ }
48+ ]
49+ }
50+ } )
51+ ] ,
52+ build : {
53+ rollupOptions : {
54+ output : {
55+ manualChunks ( id ) {
56+ if ( id . includes ( "node_modules" ) ) {
57+ return id
58+ . toString ( )
59+ . split ( "node_modules/" ) [ 1 ]
60+ . split ( "/" ) [ 0 ]
61+ . toString ( ) ;
62+ }
5863 }
5964 }
6065 }
61- }
62- } ,
63- resolve : {
64- alias : {
65- "@" : path . resolve ( __dirname , "./src" )
66- }
67- } ,
68- server : {
69- fs : {
70- allow : [ path . resolve ( __dirname ) , path . resolve ( __dirname , ".." ) ] ,
71- strict : false
66+ } ,
67+ resolve : {
68+ alias : {
69+ "@" : path . resolve ( __dirname , "./src" )
70+ }
71+ } ,
72+ server : {
73+ fs : {
74+ allow : [ path . resolve ( __dirname ) , path . resolve ( __dirname , ".." ) ] ,
75+ strict : false
76+ }
7277 }
7378 }
74- } ) ;
79+ } )
0 commit comments