1
1
import { spawn } from "node:child_process" ;
2
- import { readFile , rm , writeFile } from "node:fs/promises" ;
2
+ import { mkdir , readFile , rm , writeFile } from "node:fs/promises" ;
3
3
import { resolve } from "node:path" ;
4
4
import { rollupBuild } from "project-tool/rollup" ;
5
5
import postcss from "rollup-plugin-postcss" ;
@@ -13,6 +13,16 @@ const external = (id: string) =>
13
13
! id . includes ( "tslib" ) &&
14
14
! id . endsWith ( ".css" ) ;
15
15
16
+ // fix css path not found in legacy module bundler
17
+ const copyCss = async ( packageName : string ) => {
18
+ const cssPath = resolve ( process . cwd ( ) , "packages" , packageName , "dist" , "css" , "diff-view.css" ) ;
19
+ const cssContent = await readFile ( cssPath , "utf-8" ) ;
20
+ const legacyCssDirPath = resolve ( process . cwd ( ) , "packages" , packageName , "styles" ) ;
21
+ await mkdir ( legacyCssDirPath ) . catch ( ( ) => void 0 ) ;
22
+ const cssDistPath = resolve ( legacyCssDirPath , "diff-view.css" ) ;
23
+ await writeFile ( cssDistPath , cssContent ) ;
24
+ } ;
25
+
16
26
const clean = async ( packageName : string ) => {
17
27
const typePath = resolve ( process . cwd ( ) , "packages" , packageName , "index.d.ts" ) ;
18
28
const content = await readFile ( typePath , "utf-8" ) ;
@@ -126,6 +136,7 @@ const start = async () => {
126
136
} ,
127
137
} ) ;
128
138
await buildType ( "react" ) ;
139
+ await copyCss ( "react" ) ;
129
140
// 对于 "jsx": "preserve" 最新的rollup已经不支持解析,因此使用vite来进行打包
130
141
// https://github.com/rollup/plugins/issues/72
131
142
// https://rollupjs.org/migration/#configuration-changes
@@ -135,6 +146,7 @@ const start = async () => {
135
146
ls . on ( "error" , ( e ) => j ( e ) ) ;
136
147
} ) ;
137
148
await buildType ( "vue" ) ;
149
+ await copyCss ( "vue" ) ;
138
150
process . exit ( 0 ) ;
139
151
} ;
140
152
0 commit comments