-
Notifications
You must be signed in to change notification settings - Fork 2
/
rollup.config.js
26 lines (24 loc) · 920 Bytes
/
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
import analyze from "rollup-plugin-analyzer";
import commonjs from "@rollup/plugin-commonjs";
import json from "@rollup/plugin-json";
import nodeResolve from "@rollup/plugin-node-resolve";
import terser from "@rollup/plugin-terser";
import typescript from "@rollup/plugin-typescript";
// `npm run build` -> `production` is true
// `npm run watch` -> `production` is false
const production = !process.env.ROLLUP_WATCH;
export default {
input: "src/index.ts",
output: {
file: "dist/index.js",
format: "cjs",
},
plugins: [
nodeResolve({ preferBuiltins: true, exportConditions: ["node"] }),
json({ compact: true, preferConst: true }), // Allow requiring JSON files, e. g. const json = require('JSON')
commonjs(),
typescript(),
production && terser({ ecma: 2020, format: { comments: false } }), // minify, but only in production
production && analyze({ summaryOnly: true }),
],
};