File tree Expand file tree Collapse file tree 2 files changed +47
-1
lines changed
Expand file tree Collapse file tree 2 files changed +47
-1
lines changed Original file line number Diff line number Diff line change 2323 "./tailwind/preset" : " ./src/utils/tailwind.config.js"
2424 },
2525 "scripts" : {
26- "build" : " tsc -b" ,
26+ "build" : " tsc -b && npm run copy-assets" ,
27+ "copy-assets" : " node scripts/copy-assets.js" ,
2728 "publish:local" : " npm publish --registry http://localhost:4873" ,
29+ "unpublish:local" : " npm unpublish --registry http://localhost:4873" ,
2830 "publish:remote" : " npm publish"
2931 },
3032 "dependencies" : {
Original file line number Diff line number Diff line change 1+ const fs = require ( 'fs' ) ;
2+ const path = require ( 'path' ) ;
3+
4+ function copyAssets ( ) {
5+ const srcDir = 'src' ;
6+ const distDir = 'dist' ;
7+
8+ function copyFile ( src , dest ) {
9+ const destDir = path . dirname ( dest ) ;
10+ if ( ! fs . existsSync ( destDir ) ) {
11+ fs . mkdirSync ( destDir , { recursive : true } ) ;
12+ }
13+ fs . copyFileSync ( src , dest ) ;
14+ console . log ( `Copied: ${ src } -> ${ dest } ` ) ;
15+ }
16+
17+ function walkDir ( dir ) {
18+ if ( ! fs . existsSync ( dir ) ) {
19+ console . log ( `Source directory ${ dir } does not exist` ) ;
20+ return ;
21+ }
22+
23+ const files = fs . readdirSync ( dir ) ;
24+
25+ files . forEach ( file => {
26+ const filePath = path . join ( dir , file ) ;
27+ const stat = fs . statSync ( filePath ) ;
28+
29+ if ( stat . isDirectory ( ) ) {
30+ walkDir ( filePath ) ;
31+ } else if ( file . endsWith ( '.css' ) || file . endsWith ( '.svg' ) ) {
32+ const relativePath = path . relative ( srcDir , filePath ) ;
33+ const destPath = path . join ( distDir , relativePath ) ;
34+ copyFile ( filePath , destPath ) ;
35+ }
36+ } ) ;
37+ }
38+
39+ console . log ( 'Copying CSS and SVG assets...' ) ;
40+ walkDir ( srcDir ) ;
41+ console . log ( 'Asset copying complete!' ) ;
42+ }
43+
44+ copyAssets ( ) ;
You can’t perform that action at this time.
0 commit comments