-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrollup.config.renderer.js
59 lines (57 loc) · 1.5 KB
/
rollup.config.renderer.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
58
59
import replace from "@rollup/plugin-replace";
import alias from "@rollup/plugin-alias";
import resolve from "@rollup/plugin-node-resolve";
import postcss from "rollup-plugin-postcss";
import babel from "@rollup/plugin-babel";
import commonjs from "@rollup/plugin-commonjs";
import json from "@rollup/plugin-json";
import { terser } from "rollup-plugin-terser";
import serve from "rollup-plugin-serve";
import livereload from "rollup-plugin-livereload";
import { config } from "./package.json";
const production = !process.env.ROLLUP_WATCH;
const extensions = [".js", ".jsx", ".ts", ".tsx"];
export default {
input: "src/renderer/index.tsx",
output: {
file: "public/build/renderer_main.js",
format: "cjs",
sourcemap: true,
},
plugins: [
replace({
"process.env.NODE_ENV": JSON.stringify(
production ? "production" : "development"
),
}),
alias({
entries: [
{ find: "react", replacement: "preact/compat" },
{ find: "react-dom", replacement: "preact/compat" },
],
}),
resolve({
extensions,
}),
postcss({
extract: false,
modules: true,
use: ["sass"],
minimize: production,
}),
babel({
babelHelpers: "bundled",
extensions,
include: ["src/renderer/**/*", "src/shared/**/*"],
}),
commonjs(),
json(),
production && terser(),
!production &&
serve({
contentBase: "public",
port: config.dev_port,
}),
!production && livereload("public"),
],
};