-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.js
117 lines (103 loc) · 3.82 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
// Copyright (c) 2021. Heusala Group Oy <info@heusalagroup.fi>. All rights reserved.
import pkg from './package.json';
import resolve from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import typescript from '@rollup/plugin-typescript';
import json from '@rollup/plugin-json';
import { babel, getBabelOutputPlugin } from '@rollup/plugin-babel';
import { uglify } from "rollup-plugin-uglify";
import PATH from 'path';
import replace from '@rollup/plugin-replace';
// import externalGlobals from "rollup-plugin-external-globals";
// import inject from '@rollup/plugin-inject';
const BUILD_VERSION = process?.env?.BUILD_VERSION ?? pkg?.version ?? '';
const BUILD_NODE_ENV = process?.env?.BUILD_NODE_ENV ?? process?.env?.NODE_ENV ?? 'production';
const BUILD_DATE = new Date().toISOString() ?? '';
const BUILD_WITH_FULL_USAGE = process?.env?.BUILD_WITH_FULL_USAGE ?? '';
const BUILD_COMMAND_NAME = process?.env?.BUILD_COMMAND_NAME ?? '';
const BUILD_LOG_LEVEL = process?.env?.BUILD_LOG_LEVEL ?? '';
console.log(`Building with options:
BUILD_VERSION = '${BUILD_VERSION}'
BUILD_NODE_ENV = '${BUILD_NODE_ENV}'
BUILD_DATE = '${BUILD_DATE}'
BUILD_COMMAND_NAME = '${BUILD_COMMAND_NAME}'
BUILD_LOG_LEVEL = '${BUILD_LOG_LEVEL}'
BUILD_WITH_FULL_USAGE = '${BUILD_WITH_FULL_USAGE}'`);
export default {
input: 'src/create-backend.ts',
external: [
'node:buffer',
'node:path',
'node:child_process',
'node:process',
'node:os',
'node:url'
],
plugins: [
// See also ./src/runtime-constants.ts
replace({
exclude: 'node_modules/**',
// include: './src/build-constants.ts',
values: {
'BUILD_VERSION' : BUILD_VERSION,
'BUILD_NODE_ENV' : BUILD_NODE_ENV,
'BUILD_DATE' : BUILD_DATE,
'BUILD_COMMAND_NAME' : BUILD_COMMAND_NAME,
'BUILD_LOG_LEVEL' : BUILD_LOG_LEVEL,
'BUILD_WITH_FULL_USAGE' : BUILD_WITH_FULL_USAGE
},
preventAssignment: true,
delimiters: ['%{', '}']
}),
typescript(),
json(),
resolve(),
commonjs({
sourceMap: false,
include: /node_modules/
}),
babel({ babelHelpers: 'bundled' }),
// externalGlobals({
// intl: 'IntlPolyfill'
// }),
// See also https://github.com/mishoo/UglifyJS/blob/master/README.md#minify-options
uglify({
annotations: true,
toplevel: true,
sourcemap: false,
compress: {
collapse_vars: true,
imports: true,
booleans: true,
annotations: true,
unused: true,
dead_code: true,
passes: 10,
hoist_funs: true,
hoist_vars: true,
merge_vars: true,
toplevel: true,
unsafe_math: true
},
output: {
annotations: false,
shebang: true,
max_line_len: 120,
indent_level: 2
}
})
],
output: {
dir: 'dist',
format: 'cjs',
banner: '#!/usr/bin/env node',
plugins: [
getBabelOutputPlugin({
configFile: PATH.resolve(__dirname, 'babel.config.json')
})
]
// globals: {
// intl: 'Intl'
// }
}
};