-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrollup.config.js
55 lines (52 loc) · 1.27 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
import typescript from '@rollup/plugin-typescript';
import { nodeResolve } from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import replace from '@rollup/plugin-replace';
import copy from 'rollup-plugin-copy';
function getVersion(args) {
const environment = args.environment;
let version = null;
if (typeof environment === 'string') {
environment.split(' ').forEach((arg) => {
const [key, value] = arg.split('=');
if (key === 'version') {
version = value;
}
});
}
if (version === null) {
throw new Error('Build Version is not specified');
}
return version;
}
function config(args) {
return [
{
input: 'src/index.ts',
output: {
file: 'dist/index.js',
format: 'esm',
sourcemap: false
},
plugins: [
nodeResolve(),
replace({
__VERSION__: getVersion(args),
__DEVELOPMENT__: 'PRODUCTION'
}),
commonjs({
include: 'node_modules/**'
}),
typescript({
tsconfig: './tsconfig.json'
}),
copy({
verbose: true,
flatten: false,
targets: [{ src: ['src/templates/**/*.hbs'], dest: 'dist' }]
})
]
}
];
}
export default config;