-
Notifications
You must be signed in to change notification settings - Fork 8
/
rollup.config.mjs
50 lines (44 loc) · 1.28 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 nodeResolve from "@rollup/plugin-node-resolve";
import commonjs from "@rollup/plugin-commonjs";
import copy from "rollup-plugin-copy";
import typescript2 from "rollup-plugin-typescript2";
const BASE_CONFIG = {
input: "src/main.ts",
external: ["obsidian", "@codemirror/view", "@codemirror/state", "@codemirror/language"],
};
const getRollupPlugins = (...plugins) => [typescript2(), nodeResolve({ browser: true }), commonjs()].concat(plugins);
const DEV_PLUGIN_CONFIG = {
...BASE_CONFIG,
output: {
dir: "test-vault/.obsidian/plugins/journals",
sourcemap: "inline",
format: "cjs",
exports: "default",
name: "Journals (Development)",
},
plugins: getRollupPlugins(
copy({
targets: [{ src: ["manifest.json", "styles.css"], dest: "test-vault/.obsidian/plugins/journals/" }],
}),
),
};
const PROD_PLUGIN_CONFIG = {
...BASE_CONFIG,
output: {
dir: "build",
sourcemap: false,
format: "cjs",
exports: "default",
name: "Dataview (Production)",
},
plugins: getRollupPlugins(),
};
let configs = [];
if (process.env.BUILD === "production") {
// Production build, build library and main plugin.
configs.push(PROD_PLUGIN_CONFIG);
} else {
// Default to the dev build.
configs.push(DEV_PLUGIN_CONFIG);
}
export default configs;