-
Notifications
You must be signed in to change notification settings - Fork 7
/
rollup.config.js
83 lines (77 loc) · 1.77 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
73
74
75
76
77
78
79
80
81
82
83
const ignoreImport = require("rollup-plugin-ignore-import")
const { babel } = require("@rollup/plugin-babel")
const { terser } = require("rollup-plugin-terser")
const { nodeResolve } = require("@rollup/plugin-node-resolve")
const commonjs = require("@rollup/plugin-commonjs")
const postcss = require("rollup-plugin-postcss")
const sharedConfig = {
input: "src/main.js",
external: ["@visual-filter/common", "@visual-filter/applyer"],
}
const buildsConfig = []
if (process.env.package.startsWith("vue")) {
sharedConfig.external.push("vue")
if (process.env.package.endsWith("2")) {
Object.assign(sharedConfig, {
plugins: [
require("rollup-plugin-vue2")({
template: { isProduction: true },
}),
],
})
} else {
Object.assign(sharedConfig, { plugins: [require("rollup-plugin-vue3")()] })
}
}
sharedConfig.plugins.push(
ignoreImport({
extensions: [".css"],
}),
babel({
babelHelpers: "bundled",
extensions: [".js", ".vue", ".ts", ".tsx"],
configFile: "../../babel.config.js",
}),
terser(),
)
buildsConfig.push(
{
...sharedConfig,
output: {
file: "dist/component.esm.js",
format: "esm",
},
},
{
...sharedConfig,
output: {
file: "dist/component.cjs.js",
format: "cjs",
exports: "auto",
},
},
{
...sharedConfig,
external: "vue",
plugins: [...sharedConfig.plugins, nodeResolve(), commonjs()],
output: {
file: "dist/component.min.js",
format: "iife",
name: "VueVisualFilter",
globals: { vue: "Vue" },
},
},
{
input: "src/index.css",
output: {
file: "dist/styles.css",
},
plugins: [
postcss({
extract: true,
minimize: true,
}),
],
},
)
module.exports = buildsConfig