-
-
Notifications
You must be signed in to change notification settings - Fork 11
/
rollup.config.js
79 lines (74 loc) · 2 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import commonjs from "@rollup/plugin-commonjs";
import resolve from "@rollup/plugin-node-resolve";
import typescript from "@rollup/plugin-typescript";
import svelte from "rollup-plugin-svelte";
import { terser } from "rollup-plugin-terser";
import sveltePreprocess from "svelte-preprocess";
import postcss from "rollup-plugin-postcss";
import json from "@rollup/plugin-json";
import scss from "rollup-plugin-scss";
import replace from "rollup-plugin-replace";
import css from "rollup-plugin-css-only";
const isProduction = !process.env.ROLLUP_WATCH;
function createConfig(filename, useSvelte = false) {
return {
input: `src/${filename}.ts`,
output: {
format: "iife",
inlineDynamicImports: true,
file: `dist/build/${filename}.js`,
strict: false,
globals: ["@ffmpeg/ffmpeg"]
},
plugins: [
useSvelte && css({ output: "popup/popup.css" }),
typescript({ sourceMap: false }),
useSvelte &&
svelte({
compilerOptions: {
dev: !isProduction
},
preprocess: sveltePreprocess()
}),
json(),
resolve({
dedupe: ["svelte"]
}),
commonjs(),
!useSvelte &&
replace({
"process.env.NODE_ENV": `"${!isProduction ? "development" : "production"}"`
}),
isProduction && terser()
],
watch: {
clearScreen: true
}
};
}
function createConfigCss(filename) {
return {
input: `src/styles-injected/${filename}.scss`,
output: {
file: `dist/build/styles-injected/${filename}.css`
},
plugins: [
scss({
output: `dist/build/styles-injected/${filename}.min.css`,
outputStyle: "compressed"
}),
postcss({
extract: true
})
],
watch: {
clearScreen: true
}
};
}
export default [
createConfig("scripts/yt-downloader-content-script-initialize"),
createConfig("scripts/background"),
createConfigCss("yt-downloader-content-script-styles"),
createConfig("scripts/popup", true)
];