-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.js
64 lines (63 loc) · 1.76 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
import typescript from 'rollup-plugin-typescript2';
import { terser } from "rollup-plugin-terser";
import json from 'rollup-plugin-json';
import commonjs from 'rollup-plugin-commonjs'
import resolve from 'rollup-plugin-node-resolve';
import alias from '@rollup/plugin-alias';
import replace from '@rollup/plugin-replace';
import pkg from './package.json';
export default {
// external: Object.keys(pkg['dependencies'] || []),
input: './src/index.ts',
plugins: [
alias({
entries: {
handlebars: 'handlebars/dist/handlebars.js',
jszip: 'jszip/dist/jszip.min.js'
}
}),
replace({
// When you "each" an object in handlebars.js, "global.Symbol" is an undefined error because there is no reference to the "window" object in "global".So replace global with window.
include: '**/handlebars.*',
values: {
'global.Symbol': 'window.Symbol'
}
}),
typescript({
tsconfigDefaults: { compilerOptions: {} },
tsconfig: "tsconfig.json",
tsconfigOverride: { compilerOptions: {} },
useTsconfigDeclarationDir: true
}),
terser(),
json(),
commonjs(),
resolve({
mainFields: ['module', 'main']
})
],
output: [
// ES module (for bundlers) build.
{
format: 'esm',
file: pkg.module
},
// CommonJS (for Node) build.
{
format: 'cjs',
file: pkg.main
},
// browser-friendly UMD build
{
format: 'umd',
file: pkg.browser,
name: pkg.name
.replace(/^.*\/|\.js$/g, '')
.replace(/([-_][a-z])/g, (group) => group.toUpperCase().replace('-', '').replace('_', ''))
}
],
watch: {
exclude: 'node_modules/**',
include: 'src/**'
}
}