-
Notifications
You must be signed in to change notification settings - Fork 2
/
rollup.config.js
92 lines (90 loc) · 1.92 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
import {
external
} from '@trigen/scripts-plugin-rollup/helpers';
import tslint from 'rollup-plugin-tslint';
import json from '@rollup/plugin-json';
import commonjs from '@rollup/plugin-commonjs';
import globals from 'rollup-plugin-node-globals';
import builtins from 'rollup-plugin-node-builtins';
import typescript from 'rollup-plugin-typescript2';
import babel from '@rollup/plugin-babel';
import resolve from '@rollup/plugin-node-resolve';
import {
terser
} from 'rollup-plugin-terser';
import {
DEFAULT_EXTENSIONS
} from '@babel/core';
import pkg from './package.json';
function getPlugins(standalone, transpile = true) {
return [
tslint({
exclude: ['**/*.json', 'node_modules/**'],
throwError: true
}),
json({
preferConst: true
}),
commonjs(),
standalone && globals(),
standalone && builtins(),
typescript(),
transpile && babel({
extensions: [
...DEFAULT_EXTENSIONS,
'ts',
'tsx'
],
babelHelpers: 'runtime',
skipPreflightCheck: true
}),
standalone && resolve({
preferBuiltins: false
}),
standalone && terser()
].filter(Boolean);
}
export default [{
input: 'src/index.ts',
plugins: getPlugins(),
external: external(pkg, true),
output: [{
file: pkg.main,
format: 'cjs',
exports: 'named',
sourcemap: 'inline'
}, {
file: pkg.module,
format: 'es',
sourcemap: 'inline'
}]
}, {
input: 'src/index.ts',
plugins: getPlugins(false, false),
external: external(pkg, true),
output: {
file: pkg.raw,
format: 'es',
sourcemap: 'inline'
}
}, {
input: 'src/index.ts',
plugins: getPlugins(true),
output: {
file: pkg.umd,
format: 'umd',
exports: 'named',
name: 'i18n',
sourcemap: true
}
}, {
input: 'src/middleware.ts',
plugins: getPlugins(),
external: external(pkg, true),
output: [{
file: 'lib/middleware.js',
format: 'cjs',
exports: 'default',
sourcemap: 'inline'
}]
}];