-
Notifications
You must be signed in to change notification settings - Fork 2
/
rollup.config.mjs
44 lines (41 loc) · 1.18 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
import { nodeResolve } from '@rollup/plugin-node-resolve';
import replace from '@rollup/plugin-replace';
import run from '@rollup/plugin-run';
import typescript from '@rollup/plugin-typescript';
import fs from 'fs';
const globalNavi = fs.readFileSync('src/global.navi', 'utf-8');
/** @type {import("rollup").RollupOptions} */
const config = {
input: 'src/main.ts',
output: [
{
file: 'dist/main.js',
format: 'cjs',
sourcemap: true,
},
{
file: 'dist/module.mjs',
format: 'module',
sourcemap: true,
},
],
plugins: [
replace({
values: {
"fs.readFileSync(__dirname + '/global.navi', 'utf-8')": JSON.stringify(globalNavi),
},
delimiters: ['', ''],
preventAssignment: true,
}),
nodeResolve({ extensions: ['.mjs', '.js', '.json', '.ts'], browser: true }),
typescript(),
run({
execArgv: ['-r', 'source-map-support/register'],
}),
],
treeshake: {
preset: 'smallest',
},
};
// eslint-disable-next-line import/no-default-export
export default config;