-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.mjs
76 lines (71 loc) · 1.85 KB
/
rollup.config.mjs
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
73
74
75
76
import path from "path";
import commonjs from "@rollup/plugin-commonjs";
import resolve from "@rollup/plugin-node-resolve";
import typescript from "@rollup/plugin-typescript";
import { globbySync } from "globby";
import copy from "rollup-plugin-copy";
import del from "rollup-plugin-delete";
import peerDepsExternal from "rollup-plugin-peer-deps-external";
import postcss from "rollup-plugin-postcss";
import uglify from "rollup-plugin-uglify";
// import peerDepsExternal from "rollup-plugin-peer-deps-external";
// import resolve from "@rollup/plugin-node-resolve";
const cssConfig = globbySync(["src/**/*.css"]).map((inputFile) => {
console.log(inputFile);
return {
input: inputFile,
output: [
{
dir: `dist/css/${inputFile
.replace("src/", "")
.replace(path.basename(inputFile), "")
.replace("/css", "")}`,
sourcemap: true,
format: "es",
},
],
plugins: [
peerDepsExternal(),
resolve(),
postcss({ extensions: [".css"], extract: true }),
del({
targets: ["dist/css/**/*.js", "dist/css/**/*.js.map"],
hook: "closeBundle",
runOnce: true,
}),
],
};
});
const jsConfig = {
input: "index.ts",
output: [
{
file: "dist/index.js",
compact: true,
format: "cjs",
sourcemap: true,
exports: "named",
},
{
file: "dist/index.es.js",
format: "esm",
compact: true,
sourcemap: true,
exports: "named",
},
],
plugins: [
peerDepsExternal(),
typescript(),
commonjs(),
resolve(),
postcss({ extensions: [".css"] }),
copy({
targets: [{ src: "src/assets/images/**/*", dest: "dist/images" }],
verbose: true,
copyOnce: true,
}),
process.env.NODE_ENV === "production" && uglify.uglify(),
],
};
export default [jsConfig, ...cssConfig];