-
Notifications
You must be signed in to change notification settings - Fork 3
/
rollup.config.mjs
42 lines (40 loc) · 1.31 KB
/
rollup.config.mjs
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
import commonjs from "@rollup/plugin-commonjs";
import { nodeResolve } from "@rollup/plugin-node-resolve";
import { minify } from "rollup-plugin-esbuild";
const config = {
input: "src",
output: "_site",
};
const isProd = process.env.NODE_ENV === "production";
const pluginsProd = [nodeResolve(), commonjs(), minify()];
const pluginsDev = [nodeResolve(), commonjs()];
const plugins = isProd ? pluginsProd : pluginsDev;
const sourcemap = isProd ? false : true;
const watch = isProd ? { clearScreen: false } : {};
export default () => {
return [
{
input: `${config.input}/assets/js/main.js`,
output: { dir: `${config.output}/js`, format: "iife", sourcemap },
watch,
plugins,
},
{
input: `${config.input}/assets/js/search.js`,
output: { dir: `${config.output}/js`, format: "umd", sourcemap },
watch,
plugins,
},
{
input: `${config.input}/assets/js/scroller.js`,
output: { dir: `${config.input}/_includes/js`, format: "iife" },
plugins: pluginsProd,
},
{
input: `${config.input}/assets/js/sw.js`,
output: { file: `${config.output}/sw.js`, format: "cjs" },
watch,
plugins,
},
];
};