-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrollup.config.js
130 lines (126 loc) · 3.96 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
121
122
123
124
125
126
127
128
129
130
/* eslint-disable no-console */
import { terser } from 'rollup-plugin-terser';
import replace from 'rollup-plugin-replace';
import resolve from 'rollup-plugin-node-resolve';
import babel from 'rollup-plugin-babel';
import minifyHTML from 'rollup-plugin-minify-html-literals';
import copy from 'rollup-plugin-copy-glob';
const replacePlugin = replace({
'process.env.NODE_ENV': JSON.stringify('production'),
});
const minifyHTMLPlugin = minifyHTML({
failOnError: true,
});
const terserPlugin = terser({
warnings: true,
mangle: {
module: true,
},
});
const copyPlugin = copy([
{ files: 'node_modules/@webcomponents/webcomponentsjs/**/*.js', dest: 'build/node_modules/@webcomponents/webcomponentsjs' },
{ files: 'node_modules/@babel/polyfill/dist/polyfill.min.js', dest: 'build/node_modules/@babel/polyfill/dist' },
{ files: 'node_modules/systemjs/dist/s.min.js', dest: 'build/legacy' },
{ files: 'images/**/*', dest: 'build/images' },
{ files: 'assets/**/*', dest: 'build' },
{ files: 'assets/.well-known/*', dest: 'build/.well-known' },
]);
export default [
// modern standard config
{
input: 'src/ldf-app.js',
output: {
// output into given folder or default /build.
dir: 'build/src',
format: 'esm',
sourcemap: true,
},
onwarn(warning) {
if (warning.code !== 'CIRCULAR_DEPENDENCY') {
console.error(`(!) ${warning.message}`);
}
},
treeshake: true,
plugins: [
replacePlugin,
minifyHTMLPlugin,
resolve(),
babel({
presets: [
[
'@babel/preset-env',
{
modules: false,
targets: {
esmodules: true,
},
},
],
],
plugins: [
'@babel/plugin-syntax-dynamic-import',
'@babel/plugin-syntax-import-meta',
['bundled-import-meta', { importStyle: 'baseURI' }],
],
}),
terserPlugin,
copyPlugin,
],
},
// dam ie config
{
input: 'src/ldf-app.js',
output: {
dir: 'build/legacy/src/',
format: 'system',
sourcemap: true,
},
onwarn(warning) {
if (warning.code !== 'CIRCULAR_DEPENDENCY') {
console.error(`(!) ${warning.message}`);
}
},
plugins: [
replacePlugin,
minifyHTMLPlugin,
resolve(),
babel({
plugins: [
'@babel/plugin-transform-template-literals',
'@babel/plugin-transform-literals',
'@babel/plugin-transform-function-name',
'@babel/plugin-transform-arrow-functions',
'@babel/plugin-transform-block-scoped-functions',
'@babel/plugin-transform-classes',
'@babel/plugin-transform-object-super',
'@babel/plugin-transform-shorthand-properties',
'@babel/plugin-transform-duplicate-keys',
'@babel/plugin-transform-computed-properties',
'@babel/plugin-transform-for-of',
'@babel/plugin-transform-sticky-regex',
'@babel/plugin-transform-unicode-regex',
'@babel/plugin-transform-spread',
'@babel/plugin-transform-parameters',
'@babel/plugin-transform-destructuring',
'@babel/plugin-transform-block-scoping',
'@babel/plugin-transform-typeof-symbol',
'@babel/plugin-transform-instanceof',
[
'@babel/plugin-transform-regenerator',
{ async: false, asyncGenerators: false },
],
'@babel/plugin-transform-exponentiation-operator',
'@babel/plugin-transform-async-to-generator',
'@babel/plugin-proposal-object-rest-spread',
'@babel/plugin-proposal-async-generator-functions',
'@babel/plugin-syntax-object-rest-spread',
'@babel/plugin-syntax-async-generators',
'@babel/plugin-syntax-dynamic-import',
'@babel/plugin-syntax-import-meta',
['bundled-import-meta', { importStyle: 'baseURI' }],
],
}),
terserPlugin,
],
},
];