-
-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathrollup.config.js
60 lines (59 loc) · 2.5 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
import resolve from '@rollup/plugin-node-resolve'
import commonjs from '@rollup/plugin-commonjs'
import bundleSize from 'rollup-plugin-bundle-size'
import terser from '@rollup/plugin-terser'
import cleanup from 'rollup-plugin-cleanup'
import json from '@rollup/plugin-json'
const buildConfig = (input, outputPath, format = 'esm', minified = false, browser = false, external = [], useBundleSize = true) => {
const name = outputPath
.split('/')
.pop()
.replace(/\.(?:m|c|)js/gm, '')
let output = {
format: format,
sourcemap: true,
exports: format === 'esm' ? 'named' : 'default'
}
if (name) {
output.name = name
output.file = outputPath
} else {
output.dir = outputPath
}
const tmpConfig = []
tmpConfig.push({
input,
output,
external,
plugins: [
commonjs(),
json(),
resolve({ browser, preferBuiltins: true }),
...(useBundleSize ? [bundleSize()] : []),
cleanup() //will couse a loooooong time build
]
})
if (minified) {
let minifiedOutput = { ...output }
if (minifiedOutput.file) {
minifiedOutput.file = minifiedOutput.file.replace('.js', '.min.js').replace('.mjs', '.min.mjs').replace('cjs', '.min.cjs')
}
tmpConfig.push({
input,
output: minifiedOutput,
external,
plugins: [commonjs(), json(), resolve({ browser, preferBuiltins: true }), terser(), ...(useBundleSize ? [bundleSize()] : []), cleanup()]
})
}
return tmpConfig
}
// not yet supported all scripts that required package `Sequelize`
// include full version of backend, tweet crawler, analytics, trends
export default [
//...buildConfig('apps/backend/app.mjs', 'dist/backend/', 'esm', false, false, [], false), // full backend build success but run failed
...buildConfig('apps/backend/app_online.mjs', 'dist/backend/app_online.mjs', 'esm', false, false), // online mode
...buildConfig('apps/archiver/archive.mjs', 'dist/archiver/archive_node.mjs', 'esm', false, false),
...buildConfig('apps/archiver/archive_lite.mjs', 'dist/archiver/archive_browser.js', 'esm', true, true)
//...buildConfig('apps/open_account/scripts/get_and_upload_guest_account.mjs', 'dist/open_account/scripts/get_and_upload_guest_account.mjs', 'esm', true, false)
//...buildConfig('apps/rate_limit_checker/run.mjs', 'dist/rate_limit_checker/rate_limit_checker.mjs', 'esm', true, false)
]