forked from react-pdf/pdfkit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrollup.config.js
More file actions
80 lines (71 loc) · 2.12 KB
/
rollup.config.js
File metadata and controls
80 lines (71 loc) · 2.12 KB
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
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: 'lib/index.js',
plugins: [
nodeResolve(),
json(),
string({ include: '**/*.afm' }),
babel({
babelrc: false,
presets: [
[
'env',
{
modules: false,
targets: {
ie: '11'
}
}
]
],
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]