-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathrollup.config.js
43 lines (40 loc) · 1.08 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
import json from '@rollup/plugin-json';
import typescript from '@rollup/plugin-typescript';
import copy from 'rollup-plugin-copy';
import { terser } from 'rollup-plugin-terser';
import packageJson from './package.json';
const OUTPUT_DIR = 'build';
const manifestSubstitutions = {
__VERSION__: packageJson.version,
};
export default [
{
input: 'src/background.ts',
output: {
file: `${OUTPUT_DIR}/background.js`,
format: 'iife',
},
plugins: [
typescript(),
json(),
terser(),
copy({
targets: [
{ src: 'resources', dest: OUTPUT_DIR },
{
src: `src/manifest.json`,
dest: OUTPUT_DIR,
rename: 'manifest.json',
transform: (manifestTemplate) => {
let manifest = manifestTemplate.toString();
Object.entries(manifestSubstitutions).forEach(([variable, value]) => {
manifest = manifest.replace(new RegExp(variable, 'g'), value);
});
return manifest;
},
},
],
}),
],
},
];