-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.js
84 lines (83 loc) · 2.36 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
import commonjs from "@rollup/plugin-commonjs";
import { uglify } from "rollup-plugin-uglify";
import nodeBuiltins from "rollup-plugin-node-builtins";
import replace from 'rollup-plugin-re';
//import externalGlobals from "rollup-plugin-external-globals";
//import ignoreImport from 'rollup-plugin-ignore-import';
const ARTIFACT_NAME = "log4js";
const JS_EXT = ".js";
const SRC_DIR = "src/main/js/";
const INDEX_JS = SRC_DIR + "index" +JS_EXT;
const INDEX_FOR_BROWSERS_JS = SRC_DIR + "com/adazes/util/log4js/Logger" +JS_EXT;
const FOR_BROWSERS_SUFFIX = "-for-browsers";
const MIN_JS_EXT = ".min" +JS_EXT;
export default [
{
input: INDEX_JS,
output: [
{
file: "dist/" + ARTIFACT_NAME + JS_EXT,
format: "umd",
name: ARTIFACT_NAME
},
{
file: "dist/" + ARTIFACT_NAME + MIN_JS_EXT,
format: "umd",
name: ARTIFACT_NAME,
plugins: [uglify()]
}
],
plugins: [commonjs(), nodeBuiltins()]
},
{
input: INDEX_FOR_BROWSERS_JS,
output: [
{
file: "dist/" + ARTIFACT_NAME + FOR_BROWSERS_SUFFIX + JS_EXT,
format: "umd",
name: ARTIFACT_NAME
},
{
file: "dist/" + ARTIFACT_NAME + FOR_BROWSERS_SUFFIX + MIN_JS_EXT,
format: "umd",
name: ARTIFACT_NAME,
plugins: [uglify()]
}
],
plugins: [
// commonjs(),
replace({ // seems better than auto-generating a couple of files, etc.
replaces: {
// "import {format} from \"util\";": "//deleted"
},
patterns:[
{
include: "src/main/js/com/adazes/util/log4js/Logger.js",
test: /import \{ ?format ?\} from ["']util["'];/g,
replace: "// not using Node.js util module for browsers"
}
]
})
]
}
/* Works partially: leaves util.format while util is not defined (only function is imported, & importing everything would be wasteful)
,{
input: "src/main/js/index.js",
output: [
{
file: "dist/" +ARTIFACT_NAME+ "-for-browsers.2.js",
format: "umd",
name: ARTIFACT_NAME
},
{
file: "dist/" +ARTIFACT_NAME+ "-for-browsers.2.min.js",
format: "umd",
name: ARTIFACT_NAME
plugins: [uglify()]
}
],
plugins: [externalGlobals({util:"util"})]
}
*/
]
;