-
Notifications
You must be signed in to change notification settings - Fork 27
/
rollup.config.js
49 lines (46 loc) · 1.23 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
import json from "@rollup/plugin-json";
import { terser } from "rollup-plugin-terser";
import svg from "rollup-plugin-svg";
import progress from "rollup-plugin-progress";
import typescript from "@rollup/plugin-typescript";
import { nodeResolve } from '@rollup/plugin-node-resolve';
const fs = require("fs");
const pluginFolders = (assetFileNames) => {
const dir = fs.readdirSync(`./plugins`);
if (assetFileNames) {
return dir.filter((f) => f.match(assetFileNames));
}
return dir.filter((f) => f.match(/^datart*/));
};
export default (commandLineArgs) => {
const assetFileNames = commandLineArgs?.assetFileNames;
const plugins = pluginFolders(assetFileNames);
const config = (plugins || []).map((name) => {
return {
input: `plugins/${name}/index.js`,
output: {
file: `dist/${name}.iife.js`,
format: "iife",
},
plugins: [
nodeResolve(),
progress({
clearLine: false,
}),
json(),
svg({ base64: false }),
terser({
compress: {
defaults: false,
},
}),
typescript(),
],
watch: {
include: "plugins/**",
exclude: "node_modules/**",
},
};
});
return config;
};