-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrollup.config.mjs
59 lines (54 loc) · 1.38 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
51
52
53
54
55
56
57
58
59
import fs from 'node:fs';
import postcss from 'rollup-plugin-postcss';
import postcssPresetEnv from 'postcss-preset-env';
import terser from '@rollup/plugin-terser';
// Workaround as ESLint will not support import assertions until Stage 4
const pkg = JSON.parse(fs.readFileSync('./package.json'));
const banner =
'/*!\n' +
` * jsonpanel-next v${pkg.version}\n` +
` * (c) ${new Date().getFullYear()} Tan Zhen Yong\n` +
' * Released under the MIT License.\n' +
' */\n';
const config = [
// CommonJS and ES modules, non-minified.
{
input: 'src/main.js',
output: [
{file: pkg.main, format: 'cjs', banner},
{file: pkg.module, format: 'es', banner},
],
plugins: [
postcss({
plugins: [postcssPresetEnv()],
}),
],
},
// Minified ES build for browsers.
{
input: 'src/main.js',
output: {
file: pkg.module.replace('.js', '.min.js'),
format: 'es',
sourcemap: true,
},
plugins: [
postcss({
minimize: true,
plugins: [postcssPresetEnv()],
sourceMap: true,
}),
terser({
format: {
comments(_, {type, value}) {
if (type === 'comment2') {
// Multiline comment, pass unminified if it is copyright banner
return /\(c\)/i.test(value);
}
},
},
}),
],
},
];
export default config;