Repository navigation
Expand file tree
/
Copy pathrollup.config.js
More file actions
98 lines (96 loc) · 2.21 KB
/
Copy pathrollup.config.js
File metadata and controls
98 lines (96 loc) · 2.21 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
import nodent from "rollup-plugin-nodent";
import babel from "@rollup/plugin-babel";
import cleanup from "rollup-plugin-cleanup";
import { uglify } from "rollup-plugin-uglify";
import pkg from "./package.json";
import gzipPlugin from "rollup-plugin-gzip";
import analyze from "rollup-plugin-analyzer";
import sizes from "rollup-plugin-sizes";
import serve from "rollup-plugin-serve";
// import livereload from "rollup-plugin-livereload";
// Library Name
const libName = "autoComplete";
// Library Max. Size Allowed
const limitBytes = 3 * 1024 * 1024;
// Library Size Analyzer
const onAnalysis = ({ bundleSize }) => {
if (bundleSize < limitBytes) return;
console.log(`Bundle size exceeds ${limitBytes} bytes: ${bundleSize} bytes`);
return process.exit(1);
};
// Rollup Config.
export default [
{
input: "src/autoComplete.js",
output: {
file: pkg.browser,
name: libName,
format: "umd",
},
plugins: [
nodent({
es7: true,
promises: true,
sourcemap: true,
noRuntime: true,
es6target: true,
}),
babel({
babelHelpers: "bundled",
exclude: "node_modules/**",
presets: ["@babel/preset-env"],
}),
cleanup(),
uglify({
compress: {
toplevel: true,
drop_console: true,
},
sourcemap: true,
}),
gzipPlugin(),
],
},
{
input: "src/autoComplete.js",
output: {
file: pkg.main,
name: libName,
format: "umd",
},
plugins: [
nodent({
es7: true,
promises: true,
sourcemap: true,
noRuntime: true,
es6target: true,
}),
babel({
babelHelpers: "bundled",
exclude: "node_modules/**",
presets: ["@babel/preset-env"],
}),
cleanup(),
gzipPlugin(),
// Analyzer
analyze({
onAnalysis,
summaryOnly: true,
showExports: true,
}),
sizes(),
// Server
serve({
open: true,
openPage: "/index.html",
host: "localhost",
port: 8000,
verbose: true,
contentBase: "./dist",
}),
// // Live Reload
// livereload({ watch: "./dist" }),
],
},
];