-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrollup.js
47 lines (42 loc) · 1.31 KB
/
rollup.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
const path = require("path");
// const babel = require("rollup-plugin-babel");
// const cleanup = require("rollup-plugin-cleanup");
const rollup = require("rollup");
const glob = require("glob");
const srcDir = "./src";
const distDir = "./dist";
// ./src以下のjsファイルのリストを取得する。ただし_から始まるファイルとmodulesディレクトリは除外する。
const entries = glob.sync("**/*.js", {
ignore: ["modules/**/*.js", "**/_*/*", "**/_*"],
cwd: srcDir
});
// es3
// for (let entry of entries) {
// const inputOptions = {
// input: path.resolve(srcDir, entry),
// plugins: [babel()]
// };
// const outputOptions = {
// format: "iife",
// file: path.resolve(distDir + "/es3", entry),
// name: entry.match(".+/(.+?).[a-z]+([?#;].*)?$")[1]
// };
// build(inputOptions, outputOptions);
// }
// バンドルのみ
for (let entry of entries) {
const inputOptions = {
input: path.resolve(srcDir, entry)
// plugins: [cleanup()]
};
const outputOptions = {
format: "iife",
file: path.resolve(distDir, entry),
name: entry.match(".+/(.+?).[a-z]+([?#;].*)?$")[1]
};
build(inputOptions, outputOptions);
}
async function build(inputOptions, outputOptions) {
const bundle = await rollup.rollup(inputOptions);
await bundle.write(outputOptions);
}