-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathconfig.js
73 lines (73 loc) · 1.7 KB
/
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
const liveServer = require('rollup-plugin-live-server')
const { terser } = require('rollup-plugin-terser')
const alias = require('rollup-plugin-alias')
import babel from 'rollup-plugin-babel'
let builds = {
// Runtime+compiler ES modules build (for bundlers)
'max': {
// alias: { he: './entity-decoder.js' },
entry: 'src/platforms/gxml/entry-runtime-with-compiler.js',
dest: 'dist/geg.js',
format: 'es'
},
'min': {
// alias: { he: './entity-decoder.js' },
entry: 'src/platforms/gxml/entry-runtime-with-compiler.js',
dest: 'dist/geg.min.js',
format: 'umd'
}
}
function genConfig (name) {
const opts = builds[name]
const config = {
input: opts.entry,
external: opts.external,
plugins: [
// flow(),
liveServer({
port: 8101,
host: "0.0.0.0",
root: "./",
file: "index.html",
mount: [['/dist', './dist'], ['/src', './src'], ['/node_modules', './node_modules']],
open: false,
wait: 500
}),
babel({
include: 'src/**',
exclude: 'node_modules/**',
}),
alias({
resolve: ['.js'],
entries:[
{find:'he', replacement: './entity-decoder'}
]
})
],
output: {
file: opts.dest,
format: opts.format,
name: opts.moduleName || 'Geg'
},
onwarn: (msg, warn) => {
if (!/Circular/.test(msg)) {
warn(msg)
}
}
}
if (name === 'min') {
config.plugins.push(
terser({
toplevel: true,
output: {
ascii_only: true
},
compress: {
pure_funcs: ['makeMap']
}
})
)
}
return config
}
module.exports = genConfig(process.env.TARGET)