This repository has been archived by the owner on Nov 16, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrollup.config.babel.js
85 lines (81 loc) · 1.99 KB
/
rollup.config.babel.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
85
import path from 'path';
import babel from 'rollup-plugin-babel';
import resolve from 'rollup-plugin-node-resolve';
import commonjs from 'rollup-plugin-commonjs';
import replace from 'rollup-plugin-re';
import postcss from 'rollup-plugin-postcss';
import json from 'rollup-plugin-json';
import external from 'rollup-plugin-peer-deps-external'
export default {
input: './src/index.js',
moduleName: 'wapiti',
sourcemap: true,
external: ['react','react-dom','url','crypto','os','tty','node-readfiles','node-fetch-h2','path','stream','http','https','fs','zlib'],
targets: [
{
dest: './build/wapiti.js',
format: 'umd'
},
{
dest: 'build/wapiti.module.js',
format: 'es'
}
],
plugins: [
external(),
postcss({
modules: true
}),
json(),
babel({
exclude: 'node_modules/**'
}),
// HACK: removes formidable's attempt to overwrite `require`
replace({
patterns: [
{
test: /process\.env\.NODE_ENV/,
replace: "JSON.stringify('development')"
},
{
// regexp match with resolved path
match: /formidable(\/|\\)lib/,
// string or regexp
test: 'if (global.GENTLY) require = GENTLY.hijack(require);',
// string or function to replaced with
replace: '',
},
{
match: /types\.js$/,
test: /util\.emptyArray/,
replace: "Object.freeze ? Object.freeze([]) : []"
},
{
match: /root\.js/,
test: /util\.path\.resolve/,
replace: "require('@protobufjs/path').resolve"
}
]
}),
resolve(),
commonjs({
namedExports: {
"node_modules/protobufjs/index.js":[
"Enum",
"Field",
"MapField",
"Method",
"OneOf",
"Service",
"Namespace",
"Type",
"load"
]
}
})
],
globals: {
react: 'React',
'react-dom': 'ReactDOM'
}
};