-
Notifications
You must be signed in to change notification settings - Fork 6
/
rollup.config.js
65 lines (64 loc) · 1.59 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
// rollup.config.js
import commonjs from '@rollup/plugin-commonjs'
import resolve from '@rollup/plugin-node-resolve'
import rootImport from 'rollup-plugin-root-import'
import typescript from '@rollup/plugin-typescript'
export default args => {
const input = {
'zeswarm.kernel': 'src/kernel.ts',
'zeswarm.config': 'src/config.js',
main: 'src/main.js',
}
if (args.configMulti) {
input.main = 'src/multi/main.js'
input.zeswarm = 'src/main.js'
}
if (args.configTest) {
input.main = 'src/main.test.js'
}
return {
input,
output: {
dir: 'dist/',
// file: 'dist/main.js',
format: 'cjs',
exports: 'named',
chunkFileNames: 'zeswarm.[hash].js',
preferConst: true,
},
manualChunks(id) {
// process.stdout.write(id + '\n')
if (id.includes('node_modules')) {
return 'vendor'
}
},
plugins: [
{
name: 'custom',
banner: '/* ZeSwarm - https://github.com/ags131/ZeSwarm */',
renderChunk(code, info, opts) {
code = code.replace(/require\('\.\/(.+?)\.js'\)/g, (m, f) => `require('${f}')`)
return { code }
},
renderDynamicImport (c) {
process.stdout.write(JSON.stringify(c, null, 2) + "\n")
return {
left: 'wtf(',
right: '.slice(0, -3))'
}
}
},
rootImport({
root: `${__dirname}/src`,
useEntry: 'prepend',
extensions: '.js'
}),
resolve({
// module: true,
preferBuiltins: false
}),
typescript(),
commonjs(),
]
}
}