generated from obsidianmd/obsidian-sample-plugin
-
Notifications
You must be signed in to change notification settings - Fork 2
/
rollup.config.js
68 lines (61 loc) · 1.69 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
64
65
66
67
68
import commonjs from "@rollup/plugin-commonjs";
import typescript from "@rollup/plugin-typescript";
import postcssImport from "postcss-import";
import copy from "rollup-plugin-copy";
import postcss from "rollup-plugin-postcss";
import postcssPresetEnv from "postcss-preset-env";
const TEST_VAULT_PLUGIN_DIR =
"obsidian-fountain-editor-test/.obsidian/plugins/fountain-editor";
const BUILD_DIR = "build";
/* ------------------------------------ - ----------------------------------- */
const isProduction = process.env.BUILD === "production";
const OUT_DIR = isProduction ? BUILD_DIR : TEST_VAULT_PLUGIN_DIR;
const banner = `/*
THIS IS A GENERATED/BUNDLED FILE BY ROLLUP
if you want to view the source, visit the plugin's github repository
*/
`;
const jsConfig = {
input: "src/main.ts",
external: ["obsidian", "@codemirror/view", "@codemirror/state"],
output: {
dir: OUT_DIR,
sourcemap: "inline",
format: "cjs",
sourcemapExcludeSources: isProduction,
exports: "default",
banner: isProduction ? banner : undefined,
},
plugins: [
// postcss({
// extensions: [".css"],
// minimize: true,
// extract: path.resolve("HELP.css"),
// sourceMap: !isProduction,
// }),
typescript({
sourceMap: !isProduction,
inlineSources: !isProduction,
rootDir: "./src",
}),
commonjs(),
copy({
targets: [{ src: "manifest.json", dest: OUT_DIR }],
hook: "writeBundle",
// verbose: true,
overwrite: true,
}),
],
};
const cssConfig = {
input: "src/styles/index.css",
output: { file: OUT_DIR + "/styles.css" },
plugins: [
postcss({
extract: true,
sourceMap: !isProduction,
plugins: [postcssImport(), postcssPresetEnv()],
}),
],
};
export default [cssConfig, jsConfig];