forked from canvg/canvg
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrollup.config.js
87 lines (85 loc) · 1.93 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
import tslint from 'rollup-plugin-tslint';
import commonjs from '@rollup/plugin-commonjs';
import globals from 'rollup-plugin-node-globals';
import typescript from 'rollup-plugin-typescript2';
import replace from '@rollup/plugin-replace';
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 {
external
} from './scripts/rollup-helpers';
import pkg from './package.json';
function getPlugins(standalone, transpile = true) {
return [
tslint({
exclude: ['**/*.json', 'node_modules/**'],
throwError: true
}),
commonjs(),
standalone && globals(),
typescript(),
replace({
'process.env.NODE_ENV': JSON.stringify(
process.env.ROLLUP_WATCH
? 'development'
: 'production'
)
}),
transpile && babel({
extensions: [
...DEFAULT_EXTENSIONS,
'ts',
'tsx'
],
babelHelpers: 'runtime',
// erring otherwise in attempt to find `@babel/plugin-transform-runtime`
// added by `babel-preset-trigen`; see
// https://github.com/rollup/plugins/issues/381
skipPreflightCheck: true
}),
standalone && resolve({
preferBuiltins: false
}),
!process.env.ROLLUP_WATCH && 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: 'canvg',
sourcemap: true
}
}];