forked from CoderYiXin/unveilr
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrollup.config.js
76 lines (75 loc) · 1.89 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
import { join } from 'path'
import json from '@rollup/plugin-json'
import commonjs from '@rollup/plugin-commonjs'
import nodeResolve from '@rollup/plugin-node-resolve'
import typescript from 'rollup-plugin-typescript2'
import license from 'rollup-plugin-license'
import clear from 'rollup-plugin-clear'
import babel from '@rollup/plugin-babel'
import staticFs from 'babel-plugin-static-fs'
import obfuscator from 'rollup-plugin-obfuscator'
import { terser } from 'rollup-plugin-terser'
import { dependencies } from './package.json'
import { basename, dirname } from 'path'
const output = {
dir: 'dist',
format: 'cjs',
manualChunks(id) {
if (id.endsWith('worker.ts')) {
return ['chunk', basename(dirname(id))].join('-')
}
},
}
export default {
input: 'src/index.ts',
output,
external: Object.keys(dependencies).filter((item) => item !== 'vm2'),
plugins: [
clear({
targets: [output.dir],
}),
typescript({
tsconfigOverride: {
compilerOptions: {
module: 'ES2015',
declaration: false,
},
},
}),
babel({
babelHelpers: 'inline',
plugins: [staticFs],
}),
commonjs(),
nodeResolve({ preferBuiltins: true }),
json(),
obfuscator({
options: {
compact: false,
splitStrings: true,
debugProtection: true,
controlFlowFlattening: true,
},
}),
terser(),
license({
banner: {
commentStyle: 'ignored',
content:
'<%= pkg.name %> v<%= pkg.version %>\n' +
'(c) 2023 <%= pkg.author %>\n' +
'Released under the <%= pkg.license %> License.',
},
thirdParty: {
output: join(__dirname, 'dist', 'dependencies.txt'),
},
}),
],
cache: false,
strictDeprecations: true,
treeshake: {
moduleSideEffects: false,
propertyReadSideEffects: false,
tryCatchDeoptimization: false,
},
}