generated from obsidianmd/obsidian-sample-plugin
-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathrollup.config.js
63 lines (57 loc) · 1.45 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 typescript from '@rollup/plugin-typescript';
import { nodeResolve } from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import copy from 'rollup-plugin-copy';
const isProd = process.env.BUILD === 'production';
const banner = `/*
THIS IS A GENERATED/BUNDLED FILE BY ROLLUP
if you want to view the source visit the plugins github repository
*/
`;
const cfg = {
input: 'main.ts',
output: {
dir: isProd ? 'build' : './',
sourcemap: 'inline',
sourcemapExcludeSources: isProd,
format: 'cjs',
exports: 'default',
banner,
},
external: ['obsidian'],
plugins: [
typescript({
allowSyntheticDefaultImports: true,
}),
nodeResolve({ browser: true }),
commonjs(),
],
onwarn: (warning, warn) => {
// Quiet rollup warning about eval
if (/Use of eval is strongly discouraged/.test(warning.message)) return;
warn(warning);
},
};
if (!isProd) {
// Build by default to root of the plugin, but allow overriding if needed
// run with overrides with OUTPUT_DIR='<path>' npm run dev
const devBuildPath = process.env.OUTPUT_DIR;
if (devBuildPath) {
cfg.plugins.push(
copy({
targets: [
{ src: 'manifest.json', dest: devBuildPath },
{
src: 'styles.css',
dest: devBuildPath,
},
{
src: 'main.js',
dest: devBuildPath,
},
],
}),
);
}
}
export default cfg;