This repository has been archived by the owner on Apr 12, 2021. It is now read-only.
forked from foliojs/pdfkit
-
Notifications
You must be signed in to change notification settings - Fork 9
/
rollup.config.js
91 lines (82 loc) · 2.08 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
import babel from 'rollup-plugin-babel';
import json from 'rollup-plugin-json';
import nodeResolve from 'rollup-plugin-node-resolve';
import bundleSize from 'rollup-plugin-bundle-size';
import uglify from 'rollup-plugin-uglify';
import string from 'rollup-plugin-string';
import replace from 'rollup-plugin-replace'
import ignore from 'rollup-plugin-ignore'
import pkg from './package.json';
const cjs = {
exports: 'named',
format: 'cjs'
}
const esm = {
format: 'es'
}
const getCJS = override => Object.assign({}, cjs, override)
const getESM = override => Object.assign({}, esm, override)
const configBase = {
input: 'src/index.js',
plugins: [
nodeResolve(),
json(),
string({ include: '**/*.afm' }),
babel({
babelrc: false,
presets: [['es2015', { modules: false }]],
plugins: ['external-helpers'],
runtimeHelpers: true
}),
bundleSize(),
],
external: Object.keys(pkg.dependencies)
}
const serverConfig = Object.assign({}, configBase, {
output: [
getESM({ file: 'dist/pdfkit.es.js' }),
getCJS({ file: 'dist/pdfkit.cjs.js' }),
],
plugins: configBase.plugins.concat(
replace({
BROWSER: JSON.stringify(false),
})
),
external: configBase.external.concat(['fs'])
})
const serverProdConfig = Object.assign({}, serverConfig, {
output: [
getESM({ file: 'dist/pdfkit.es.min.js' }),
getCJS({ file: 'dist/pdfkit.cjs.min.js' }),
],
plugins: serverConfig.plugins.concat(
uglify()
),
})
const browserConfig = Object.assign({}, configBase, {
output: [
getESM({ file: 'dist/pdfkit.browser.es.js' }),
getCJS({ file: 'dist/pdfkit.browser.cjs.js' }),
],
plugins: configBase.plugins.concat(
replace({
BROWSER: JSON.stringify(true)
}),
ignore(['fs'])
)
})
const browserProdConfig = Object.assign({}, browserConfig, {
output: [
getESM({ file: 'dist/pdfkit.browser.es.min.js' }),
getCJS({ file: 'dist/pdfkit.browser.cjs.min.js' }),
],
plugins: browserConfig.plugins.concat(
uglify()
),
})
export default [
serverConfig,
serverProdConfig,
browserConfig,
browserProdConfig
]