-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrollup.config.js
More file actions
180 lines (167 loc) · 4.76 KB
/
rollup.config.js
File metadata and controls
180 lines (167 loc) · 4.76 KB
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
import html from '@web/rollup-plugin-html';
import polyfillsLoader from '@web/rollup-plugin-polyfills-loader';
import {copy} from '@web/rollup-plugin-copy';
import resolve from '@rollup/plugin-node-resolve';
import {getBabelOutputPlugin} from '@rollup/plugin-babel';
import {terser} from 'rollup-plugin-terser';
import minifyHTML from 'rollup-plugin-minify-html-literals';
import summary from 'rollup-plugin-summary';
/*
export default {
input: 'deploy/application-shell.js',
output: {
file: 'application-shell.bundled.js',
format: 'esm',
},
onwarn(warning) {
if (warning.code !== 'THIS_IS_UNDEFINED') {
console.error(`(!) ${warning.message}`);
}
},
plugins: [
replace({'Reflect.decorate': 'undefined'}),
resolve(),
terser({
ecma: 2017,
module: true,
warnings: true,
mangle: {
properties: {
regex: /^__/,
},
},
}),
summary(),
],
};
*/
export default {
plugins: [
// Entry point for application build; can specify a glob to build multiple
// HTML files for non-SPA app
html({
input: 'index.html',
}),
// Resolve bare module specifiers to relative paths
resolve(),
// Minify HTML template literals
minifyHTML(),
// Minify JS
terser({
ecma: 2020,
module: true,
warnings: true,
}),
// Print bundle summary
summary(),
// Optional: copy any static assets to build directory
copy({
patterns: ['images/**/*', 'manifest.json', 'polymer.json', 'sitemap.xml', 'sw.js', 'robots.txt', 'ads.txt', 'firebase-messaging-sw.js', 'TERMS.md' ],
}),
],
output: {
dir: 'public/dist',
format: 'es', // immediately-invoked function expression — suitable for <script> tags
sourcemap: true
},
preserveEntrySignatures: 'strict',
};
/*
// Configure an instance of @web/rollup-plugin-html
const htmlPlugin = html({
rootDir: './',
flattenOutput: false,
});
export default {
// Entry point for application build; can specify a glob to build multiple
// HTML files for non-SPA app
input: 'index.html',
plugins: [
htmlPlugin,
// Resolve bare module specifiers to relative paths
resolve(),
// Minify HTML template literals
minifyHTML(),
// Minify JS
terser({
module: true,
warnings: true,
}),
// Inject polyfills into HTML (core-js, regnerator-runtime, webcoponents,
// lit/polyfill-support) and dynamically loads modern vs. legacy builds
polyfillsLoader({
modernOutput: {
name: 'modern',
},
// Feature detection for loading legacy bundles
legacyOutput: {
name: 'legacy',
test: '!!Array.prototype.flat',
type: 'systemjs',
},
// List of polyfills to inject (each has individual feature detection)
polyfills: {
hash: true,
coreJs: true,
regeneratorRuntime: true,
fetch: true,
webcomponents: true,
// Custom configuration for loading Lit's polyfill-support module,
// required for interfacing with the webcomponents polyfills
custom: [
{
name: 'lit-polyfill-support',
path: 'node_modules/lit/polyfill-support.js',
test: "!('attachShadow' in Element.prototype)",
module: false,
},
],
},
}),
// Print bundle summary
summary(),
// Optional: copy any static assets to build directory
copy({
patterns: ['images//', 'manifest.json', 'polymer.json', 'sitemap.xml', 'sw.js', 'robots.txt', 'ads.txt', 'firebase-messaging-sw.js', 'TERMS.md' ],
}),
],
// Specifies two JS output configurations, modern and legacy, which the HTML plugin will
// automatically choose between; the legacy build is compiled to ES5
// and SystemJS modules
output: [
{
// Modern JS bundles (no JS compilation, ES module output)
format: 'esm',
chunkFileNames: '[name]-[hash].js',
entryFileNames: '[name]-[hash].js',
dir: 'build',
plugins: [htmlPlugin.api.addOutput('modern')],
},
{
// Legacy JS bundles (ES5 compilation and SystemJS module output)
format: 'esm',
chunkFileNames: 'legacy-[name]-[hash].js',
entryFileNames: 'legacy-[name]-[hash].js',
dir: 'build',
plugins: [
htmlPlugin.api.addOutput('legacy'),
// Uses babel to compile JS to ES5 and modules to SystemJS
getBabelOutputPlugin({
compact: true,
presets: [
[
'@babel/preset-env',
{
targets: {
ie: '11',
},
modules: 'systemjs',
},
],
],
}),
],
},
],
preserveEntrySignatures: false,
};*/