-
Notifications
You must be signed in to change notification settings - Fork 3
/
rollup.config.mjs
50 lines (46 loc) · 1.32 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
43
44
45
46
47
48
49
50
import commonjs from "@rollup/plugin-commonjs";
import { nodeResolve } from "@rollup/plugin-node-resolve";
import typescript from "@rollup/plugin-typescript";
import fs from "fs";
import minifyHTML from "rollup-plugin-minify-html-literals";
import { terser } from "rollup-plugin-terser";
const pkg = JSON.parse(fs.readFileSync("package.json", { encoding: "utf8" }));
const banner = `/**!
* @license
* sdpi-components v${pkg.version}, Copyright Corsair Memory Inc. and other contributors (${pkg.homepage})
* Lit, Copyright 2019 Google LLC, SPDX-License-Identifier: BSD-3-Clause (https://lit.dev/)
*/`;
export default (commandLineArgs) => {
// Determine the environment, and remove the command line to prevent warnings.
// eslint-disable-next-line no-undef
const dev = !!(process.env.ROLLUP_WATCH || commandLineArgs.dev);
delete commandLineArgs.dev;
/**
* @type {import('rollup').RollupOptions}
*/
const config = {
input: "src/index.ts",
output: {
file: dev ? `example/pi/sdpi-components.js` : `dist/sdpi-components.js`,
format: "iife",
sourcemap: dev,
banner,
},
plugins: [
!dev && minifyHTML.default(),
typescript({
sourceMap: dev,
inlineSources: dev,
}),
nodeResolve(),
commonjs(),
!dev &&
terser({
format: {
comments: /^\*!/,
},
}),
],
};
return config;
};