-
-
Notifications
You must be signed in to change notification settings - Fork 13
/
rollup.config.mjs
50 lines (46 loc) · 1.15 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
import copy from "@guanghechen/rollup-plugin-copy";
import styles from "rollup-plugin-styler";
import { string } from "rollup-plugin-string";
import terser from "@rollup/plugin-terser";
import { distDirectory, packageId, sourceDirectory } from "./tools/const.mjs";
const staticFiles = [
"assets",
"CHANGELOG.md",
"lang",
"libs",
"LICENSE.md",
"media",
"module.json",
"README.md",
"templates",
];
const isProduction = process.env.NODE_ENV === "production";
/**
* @type {import('rollup').RollupOptions}
*/
const config = {
input: { [`${packageId}`]: `${sourceDirectory}/${packageId}.js` },
output: {
dir: distDirectory,
format: "es",
sourcemap: true,
assetFileNames: "[name].[ext]",
},
plugins: [
styles({
mode: ["extract", `css/${packageId}.css`],
url: false,
sourceMap: true,
minimize: isProduction,
}),
string({
include: [`${sourceDirectory}/**/*.frag`, `${sourceDirectory}/**/*.vert`],
}),
copy({
verbose: true,
targets: [{ src: staticFiles, dest: distDirectory }],
}),
isProduction && terser({ ecma: 2020, keep_fnames: true }),
],
};
export default config;