File tree Expand file tree Collapse file tree 3 files changed +27
-258
lines changed
Expand file tree Collapse file tree 3 files changed +27
-258
lines changed Original file line number Diff line number Diff line change 3535 }
3636 },
3737 "scripts" : {
38- "build" : " tsdown && pnpm css:copy" ,
39- "build:watch" : " concurrently 'tsdown --watch ./src --no-clean' 'pnpm css:watch'" ,
40- "css:copy" : " rsync -a --include='*/' --include='*.css' --exclude='*' src/presets/ dist/default/presets/" ,
41- "css:watch" : " chokidar 'src/presets/**/*.css' --initial -c 'pnpm run css:copy'" ,
38+ "build" : " tsdown" ,
39+ "build:watch" : " tsdown --watch ./src --no-clean" ,
4240 "dev" : " pnpm build:watch" ,
4341 "test" : " vitest run" ,
4442 "test:watch" : " vitest" ,
5553 "devDependencies" : {
5654 "@testing-library/react" : " ^16.3.0" ,
5755 "@types/react" : " ^19.2.7" ,
58- "chokidar-cli" : " ^3.0.0" ,
59- "concurrently" : " ^9.2.1" ,
6056 "jsdom" : " ^26.1.0" ,
6157 "react" : " ^19.2.1" ,
6258 "react-dom" : " ^19.2.1" ,
Original file line number Diff line number Diff line change @@ -6,18 +6,8 @@ type BuildMode = 'dev' | 'default';
66
77const buildModes : BuildMode [ ] = [ 'dev' , 'default' ] ;
88
9- const presetsEntries = Object . fromEntries (
10- globSync ( 'src/presets/**/*.{ts,tsx}' ) . map ( ( file ) => {
11- const key = file . replace ( 'src/' , '' ) . replace ( / \. t s x ? $ / , '' ) ;
12- return [ key , file ] ;
13- } )
14- ) ;
15-
16- const createConfig = ( mode : BuildMode ) : UserConfig => ( {
17- entry : {
18- index : './src/index.ts' ,
19- ...presetsEntries ,
20- } ,
9+ const createConfig = ( mode : BuildMode , isWatch : boolean ) : UserConfig => ( {
10+ entry : 'src/**/index.ts' ,
2111 platform : 'browser' ,
2212 format : 'es' ,
2313 sourcemap : true ,
@@ -32,6 +22,27 @@ const createConfig = (mode: BuildMode): UserConfig => ({
3222 __DEV__ : mode === 'dev' ? 'true' : 'false' ,
3323 } ,
3424 dts : mode === 'dev' ,
25+ copy : [
26+ {
27+ from : 'src/**/*.css' ,
28+ to : `dist/${ mode } ` ,
29+ flatten : false ,
30+ } ,
31+ ] ,
32+ plugins : [
33+ {
34+ name : 'watch-css' ,
35+ buildStart ( ) {
36+ const cssFiles = globSync ( 'src/**/*.css' ) ;
37+ for ( const file of cssFiles ) {
38+ this . addWatchFile ( file ) ;
39+ }
40+ } ,
41+ } ,
42+ ] ,
3543} ) ;
3644
37- export default defineConfig ( buildModes . map ( ( mode ) => createConfig ( mode ) ) ) ;
45+ export default defineConfig ( ( cliOptions ) => {
46+ const isWatch = ! ! cliOptions . watch ;
47+ return buildModes . map ( ( mode ) => createConfig ( mode , isWatch ) ) ;
48+ } ) ;
You can’t perform that action at this time.
0 commit comments