forked from larslockefeer/obsidian-plugin-todo
-
Notifications
You must be signed in to change notification settings - Fork 6
/
rollup.config.js
51 lines (47 loc) · 1.25 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
//npm run build
//npm run dev
import typescript from '@rollup/plugin-typescript';
import { nodeResolve } from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import fs from 'fs';
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 plugin's github repository at
https://github.com/zsviczian/obsidian-stakeholder-actions
*/
`;
export default {
input: './src/main.ts',
output: {
dir: 'dist',
sourcemap: 'inline',
// sourcemapExcludeSources: isProd,
format: 'cjs',
exports: 'default',
banner,
},
external: ['obsidian'],
plugins: [
copyAndWatch('src/styles.css', 'styles.css'),
copyAndWatch('src/manifest.json', 'manifest.json'),
nodeResolve({ browser: true }),
typescript({ inlineSources: !isProd }),
commonjs(),
],
};
function copyAndWatch(fileIn, fileOut, isProd) {
return {
name: 'copy-and-watch',
async buildStart() {
this.addWatchFile(fileIn);
},
async generateBundle() {
this.emitFile({
type: 'asset',
fileName: fileOut,
source: fs.readFileSync(fileIn),
});
},
};
}