-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrollup.config.js
57 lines (52 loc) · 1.58 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
// rollup.config.js
// https://rollupjs.org/guide/en/
import terser from "@rollup/plugin-terser";
import { nodeResolve } from "@rollup/plugin-node-resolve";
/* Hack for unusual ESM/npm package structure - oudated plugin */
/* https://github.com/shuizhongyueming/rollup-plugin-output-manifest/issues/21#issuecomment-1368169746 */
import pluginManifest from "rollup-plugin-output-manifest";
const { default: outputManifest } = pluginManifest;
const devMode = process.env.NODE_ENV !== "production";
// Options for creating hash manifest of the outputs.
const manifestOpts = {
isMerge: true,
fileName: "../../src/_data/manifest.json",
};
const noop = () => {};
export default [
{
input: "./src/js/main.js",
plugins: [nodeResolve(), devMode ? noop() : outputManifest(manifestOpts)],
output: {
entryFileNames: devMode ? "bundle.esm.js" : "bundle-[hash].esm.js",
generatedCode: "es2015",
name: "bundle",
format: "es",
dir: "./_site/js/",
sourcemap: devMode ? "inline" : false,
plugins: [
devMode
? noop()
: terser({
ecma: 2020,
mangle: { toplevel: true },
compress: {
module: true,
toplevel: true,
unsafe_arrows: true,
drop_console: !devMode,
drop_debugger: !devMode,
},
output: {
quote_style: 1,
comments: false,
},
}),
],
},
watch: {
include: "./src/js/**",
clearScreen: false,
},
},
];