-
Notifications
You must be signed in to change notification settings - Fork 1
/
rollup.config.js
120 lines (109 loc) · 3 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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
import analyze from "rollup-plugin-analyzer";
import babel from "rollup-plugin-babel";
import minify from "rollup-plugin-babel-minify";
import copy from "rollup-plugin-copy";
import filesize from "rollup-plugin-filesize";
import resolve from "rollup-plugin-node-resolve";
import replace from "rollup-plugin-replace";
import json from "rollup-plugin-json";
import url from "rollup-plugin-url";
export default () => {
const dest = "dist";
const buildType = "production";
const es5BabelTranspilation = babel();
const es6BabelTranspilation = babel({
presets: [["@babel/preset-env", { targets: { esmodules: true } }]],
});
const basePlugins = [
replace({ "process.env.NODE_ENV": JSON.stringify(buildType) }),
resolve(),
minify({ comments: false }),
analyze(),
filesize(),
json(),
url({
include: ["**/*.woff", "**/*.woff2", "**/*.ttf"],
limit: Infinity,
}),
];
const copyTask = copy({
targets: [
{ src: "src/index.html", dest },
{ src: "src/fonts", dest },
{ src: "node_modules/@webcomponents/webcomponentsjs/bundles", dest },
{
src: "node_modules/@webcomponents/webcomponentsjs/webcomponents-loader.js",
dest,
},
],
verbose: true,
});
const stackedSheetEs5 = {
input: ["src/components/stacked-sheet.js"],
output: {
file: `${dest}/stacked-sheet.es5.js`,
format: "umd",
sourcemap: true,
name: "stackedSheetEs5",
},
plugins: [...basePlugins, es5BabelTranspilation, copyTask],
};
const stackedSheetEs6 = {
input: ["src/components/stacked-sheet.js"],
output: {
file: `${dest}/stacked-sheet.js`,
format: "es",
sourcemap: true,
name: "stackedSheetEs6",
},
plugins: [...basePlugins, es6BabelTranspilation],
};
const stackedSheetsHolderEs5 = {
input: ["src/components/stacked-sheets-holder.js"],
output: {
file: `${dest}/stacked-sheets-holder.es5.js`,
format: "umd",
sourcemap: true,
name: "stackedSheetHolderEs5",
},
plugins: [...basePlugins, es5BabelTranspilation, copyTask],
};
const stackedSheetsHolderEs6 = {
input: ["src/components/stacked-sheets-holder.js"],
output: {
file: `${dest}/stacked-sheets-holder.js`,
format: "es",
sourcemap: true,
name: "stackedSheetHolderEs6",
},
plugins: [...basePlugins, es6BabelTranspilation],
};
const myAppEs5 = {
input: ["src/my-app.js"],
output: {
file: `${dest}/my-app.es5.js`,
format: "umd",
sourcemap: true,
name: "stackedSheetDemoEs5",
},
plugins: [...basePlugins, es5BabelTranspilation, copyTask],
};
const myAppEs6 = {
input: ["src/my-app.js"],
output: {
file: `${dest}/my-app.js`,
format: "es",
sourcemap: true,
name: "stackedSheetDemoEs6",
},
plugins: [...basePlugins, es6BabelTranspilation],
};
return [
stackedSheetEs5,
stackedSheetEs6,
stackedSheetsHolderEs5,
stackedSheetsHolderEs6,
myAppEs5,
myAppEs6,
];
};