This repository has been archived by the owner on Mar 21, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrollup.config.js
72 lines (66 loc) · 1.7 KB
/
rollup.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import fs from "fs";
import path from "path";
import { fileURLToPath } from "url";
import url from "@rollup/plugin-url";
import postcss from "rollup-plugin-postcss";
import vue from "rollup-plugin-vue";
import images from "rollup-plugin-image-files";
import meta from "./package.json";
const packagePath = path.join(
path.dirname(fileURLToPath(import.meta.url)),
"./packages"
);
const NOT_EXPORT = ["common"];
const exportPackages = [
["index", path.join(packagePath, "index.js")],
...fs
.readdirSync(packagePath)
.filter(
(p) =>
!NOT_EXPORT.includes(p) &&
fs.statSync(path.join(packagePath, p)).isDirectory()
)
.map((p) => [`rq-${p}`, path.join(packagePath, p, "index.js")]),
];
const componentsConfig = exportPackages.map(([fileName, filePath]) => ({
input: filePath,
output: {
file: `lib/${fileName}.js`,
format: "esm",
sourcemap: true,
},
plugins: [
images({ extensions: ["png", "avif", "webp"] }),
vue({ css: false, needMap: false }),
postcss({
extract: `theme/${fileName}.css`,
sourceMap: true,
}),
],
external: (id) =>
new RegExp(
`^(${Object.keys({
...meta.dependencies,
...meta.peerDependencies,
}).join("|")})($|/)`
).test(id),
}));
const baseCssConfig = {
input: "./packages/common/style/index.js",
output: {
file: "lib/theme/base.js",
},
plugins: [
url({
include: ["**/*.eot", "**/*.woff", "**/*.woff2", "**/*.ttf", "**/*.svg"],
limit: 0,
fileName: "[name][extname]",
}),
postcss({
extract: "base.css",
sourceMap: true,
}),
],
external: ["@rqjs/rqthemes/lib/vars.css"],
};
export default [...componentsConfig, baseCssConfig];