-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrollup.config.js
89 lines (83 loc) · 2.21 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
84
85
86
87
88
89
import resolve from "@rollup/plugin-node-resolve";
import commonjs from "@rollup/plugin-commonjs";
import externals from "rollup-plugin-node-externals";
import alias from "@rollup/plugin-alias";
import { getBabelOutputPlugin } from "@rollup/plugin-babel";
import terser from "@rollup/plugin-terser";
// CommonJS build
const cjs = {
input: "./src/syntax/index.js",
output: [
{
file: `./dist/ecsstree.cjs`,
format: "cjs",
exports: "auto",
sourcemap: false,
},
],
plugins: [externals(), commonjs({ sourceMap: false }), resolve({ preferBuiltins: false })],
};
// ECMAScript build
const esm = {
input: "./src/syntax/index.js",
output: [
{
file: `./dist/ecsstree.esm.js`,
format: "esm",
sourcemap: false,
},
],
plugins: [externals(), commonjs({ sourceMap: false }), resolve({ preferBuiltins: false })],
};
const browserPlugins = [
commonjs({ sourceMap: false }),
resolve({ preferBuiltins: false, browser: true }),
alias({
entries: [
{
find: "css-tree",
replacement: "node_modules/css-tree/dist/csstree.esm.js",
},
],
}),
getBabelOutputPlugin({
presets: [
[
"@babel/preset-env",
{
targets: ["> 1%", "not dead"],
},
],
],
allowAllFormats: true,
}),
terser(),
];
// Browser-friendly UMD build
const umd = {
input: "./src/syntax/index.js",
output: [
{
file: `./dist/ecsstree.umd.min.js`,
name: "ECSSTree",
format: "umd",
sourcemap: false,
},
],
plugins: browserPlugins,
};
// Browser-friendly IIFE build
const iife = {
input: "./src/syntax/index.js",
output: [
{
file: `./dist/ecsstree.iife.min.js`,
name: "ECSSTree",
format: "iife",
sourcemap: false,
},
],
plugins: browserPlugins,
};
// Export build configs for Rollup
export default [cjs, esm, umd, iife];