forked from SkyCryptWebsite/SkyCrypt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.js
57 lines (54 loc) · 2.05 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
import typescript from "@rollup/plugin-typescript";
import resolve from "@rollup/plugin-node-resolve";
import commonjs from "@rollup/plugin-commonjs";
import terser from "@rollup/plugin-terser";
import minifyHTML from "rollup-plugin-minify-html-literals";
import nameMap from "./lib/rollup-plugin-name-map.js";
import del from "rollup-plugin-delete";
import replace from "@rollup/plugin-replace";
// `pnpm start` -> `production` is true
// `pnpm dev` -> `production` is false
const production = !process.env.ROLLUP_WATCH;
/**
* @type {import('rollup').RollupOptions}
*/
const CONFIG = {
input: [
"public/resources/ts/browser-compat-check.ts",
"public/resources/ts/common-defer.ts",
"public/resources/ts/common.ts",
"public/resources/ts/stats-defer.ts",
"public/resources/ts/development-defer.ts",
"public/resources/ts/themes.ts",
"public/resources/ts/elements/bonus-stats.ts",
"public/resources/ts/elements/local-time.ts",
"public/resources/ts/elements/rich-item.ts",
"public/resources/ts/elements/skill-component.ts",
"public/resources/ts/elements/player-stat.ts",
],
output: {
dir: "public/resources/js",
format: "es",
sourcemap: true,
entryFileNames: "[name].[hash].js",
chunkFileNames: "[name].[hash].js",
},
plugins: [
del({ targets: "public/resources/js/*" }),
replace({ "process.env.NODE_ENV": JSON.stringify(production ? "production" : "development") }), // makes process.env.NODE_ENV work on client side
typescript({ tsconfig: "public/resources/ts/tsconfig.json" }), // converts TypeScript modules to JavaScript
resolve(), // tells Rollup how to stuff in node_modules
commonjs(), // converts Node modules to ES modules
production && terser(), // minify, but only in production
production && // minify html strings inside javascript (aka lit-html)
minifyHTML.default({
options: {
minifyOptions: {
conservativeCollapse: true,
},
},
}),
nameMap("public/resources/js/file-name-map.json"),
],
};
export default CONFIG;