Skip to content

Commit 84f4229

Browse files
fix css bundler
1 parent 15a93b6 commit 84f4229

File tree

4 files changed

+16
-1
lines changed

4 files changed

+16
-1
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ lerna-debug.log*
99

1010
node_modules
1111
dist
12+
styles
1213
dist-ssr
1314
*.local
1415

packages/react/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"types": "index.d.ts",
99
"files": [
1010
"dist",
11+
"styles",
1112
"index.js",
1213
"index.d.ts"
1314
],

packages/vue/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"types": "index.d.ts",
1010
"files": [
1111
"dist",
12+
"styles",
1213
"index.cjs",
1314
"index.d.ts"
1415
],

scripts/build.ts

+13-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
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";
33
import { resolve } from "node:path";
44
import { rollupBuild } from "project-tool/rollup";
55
import postcss from "rollup-plugin-postcss";
@@ -13,6 +13,16 @@ const external = (id: string) =>
1313
!id.includes("tslib") &&
1414
!id.endsWith(".css");
1515

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+
1626
const clean = async (packageName: string) => {
1727
const typePath = resolve(process.cwd(), "packages", packageName, "index.d.ts");
1828
const content = await readFile(typePath, "utf-8");
@@ -126,6 +136,7 @@ const start = async () => {
126136
},
127137
});
128138
await buildType("react");
139+
await copyCss("react");
129140
// 对于 "jsx": "preserve" 最新的rollup已经不支持解析,因此使用vite来进行打包
130141
// https://github.com/rollup/plugins/issues/72
131142
// https://rollupjs.org/migration/#configuration-changes
@@ -135,6 +146,7 @@ const start = async () => {
135146
ls.on("error", (e) => j(e));
136147
});
137148
await buildType("vue");
149+
await copyCss("vue");
138150
process.exit(0);
139151
};
140152

0 commit comments

Comments
 (0)