-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.common.config.js
53 lines (47 loc) · 1.28 KB
/
rollup.common.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
import "dotenv/config";
import { env } from "process";
import url from "@rollup/plugin-url";
import json from "@rollup/plugin-json";
import alias from "@rollup/plugin-alias";
import styles from "rollup-plugin-styles";
import replace from "@rollup/plugin-replace";
import typescript from "@rollup/plugin-typescript";
import nodeResolve from "@rollup/plugin-node-resolve";
import { terser } from "rollup-plugin-terser";
import pkg from "./package.json";
const toReplace = {
preventAssignment: true,
__public__: "/build",
"import.meta.env.LIST_ID": JSON.stringify(env.LIST_ID),
"import.meta.env.GTAG_ID": JSON.stringify(env.GTAG_ID),
"import.meta.env.BASE_NETLIFY_URL": JSON.stringify(env.BASE_NETLIFY_URL),
};
const isProduction = env.NODE_ENV === "production";
export const plugins = ({
replaceOptions = {},
urlOptions = {},
stylesOptions = {},
additionalPlugins = [],
} = {}) => [
replace({ ...toReplace, ...replaceOptions }),
alias({
entries: [],
}),
url({
limit: 0,
fileName: `[name][extname]`,
...urlOptions,
}),
json(),
styles({
mode: "extract",
onExtract: () => true,
url: false,
minimize: isProduction,
...stylesOptions,
}),
typescript(),
nodeResolve({ resolveOnly: Object.keys(pkg.dependencies) }),
...additionalPlugins,
isProduction ? terser() : null,
];