-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrollup.config.js
43 lines (38 loc) · 1.26 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 { globSync } from "glob";
import _ from "lodash";
import { defineConfig } from "rollup";
import nodeResolve from "rollup-plugin-node-resolve";
import commonjs from "rollup-plugin-commonjs";
// import handlebars from "rollup-plugin-handlebars-plus";
import productionConfig from "./config/rollup.config.prod.js";
import developmentConfig from "./config/rollup.config.dev.js";
export default args => {
const inputFilenames = globSync("./src/*.js", { dotRelative: true }).map(filePath => {
const pathSegments = filePath.split(/\/|\\/);
const filename = pathSegments[pathSegments.length - 1];
const filenameWithoutExtension = filename.slice(0, filename.lastIndexOf("."));
return filenameWithoutExtension;
});
return inputFilenames.map(filename => {
const baseConfiguration = defineConfig({
input: `./src/${filename}.js`,
output: {
file: `./build/${filename}.js`,
format: "iife",
},
plugins: [
nodeResolve(),
commonjs({
include: "node_modules/**"
}),
// handlebars(),
],
});
if (args.dev) {
return _.merge(baseConfiguration, developmentConfig);
}
else {
return _.merge(baseConfiguration, productionConfig(`${filename}.js`));
}
});
};