This repository has been archived by the owner on Aug 29, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.js
59 lines (58 loc) · 1.49 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
import babel from '@rollup/plugin-babel';
import resolve from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import replace from '@rollup/plugin-replace';
import { terser } from 'rollup-plugin-terser';
import { join } from 'path';
import builtins from 'builtin-modules';
const config = {
output: {
file: "",
name: "rollup-plugin-hotreload",
format: 'umd',
sourcemap: true,
globals: {
crypto: 'crypto',
fs: 'fs',
path: 'path',
stream: 'stream',
http: 'http'
}
},
external: builtins,
plugins: [
resolve({
module: true,
jsnext: true,
main: true,
browser: true,
}),
commonjs(),
babel({
babelHelpers: 'external',
exclude: 'node_modules/**'
}),
replace({
exclude: 'node_modules/**',
ENV: JSON.stringify(process.env.NODE_ENV || "development"),
}),
terser(),
]
};
function bundle(config, dirname, outputpath, sourcefilepath) {
const buildModule = { module: null, outputPath: null };
const output1 = Object.assign({}, config.output, {
file: join(dirname, outputpath)
});
const module1 = Object.assign({}, config, {
input: join(dirname, sourcefilepath),
output: output1,
});
buildModule.module = module1;
buildModule.outputPath = outputpath;
return buildModule;
}
export default [
bundle(config, __dirname, "build/index.min.js", "src/index.js").module,
bundle(config, __dirname, "build/hotreload.min.js", "lib/hotreload.js").module
];