-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.js
63 lines (60 loc) · 1.65 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
58
59
60
61
62
63
import pkg from "./package.json" assert { type: "json" };
import wq from "@wq/rollup-plugin";
import babel from "@rollup/plugin-babel";
import resolve from "@rollup/plugin-node-resolve";
import commonjs from "@rollup/plugin-commonjs";
import replace from "@rollup/plugin-replace";
import terser from "@rollup/plugin-terser";
import analyze from "rollup-plugin-analyze";
const banner = `/*
* ${pkg.name} ${pkg.version}
* ${pkg.description}
* (c) 2013-2023, S. Andrew Sheppard
* https://wq.io/license
*/
`;
const config = {
input: "src/index.js",
plugins: [
wq(),
babel({
plugins: ["@babel/transform-react-jsx"],
babelHelpers: "inline",
}),
commonjs(),
resolve(),
terser({ keep_fnames: /^([A-Z]|use[A-Z])/ }), // Preserve component & hook names
analyze({ limit: 10 }),
],
output: {
file: "markdown.js",
banner,
format: "esm",
sourcemap: true,
},
},
replaceConfig = {
"process.env.NODE_ENV": '"production"',
"proc.cwd()": '""',
"module.exports = browser$1;": "",
delimiters: ["", ""],
};
export default [
{
...config,
plugins: [
replace({
...replaceConfig,
"./wq.js": "https://unpkg.com/wq",
}),
...config.plugins,
],
output: {
...config.output,
file: "markdown.js",
sourcemapPathTransform(path) {
return path.replace("./", "wq/markdown/");
},
},
},
];