This repository has been archived by the owner on Apr 22, 2021. It is now read-only.
forked from foliojs/fontkit
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathrollup.config.js
91 lines (82 loc) · 2.19 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 localResolve from 'rollup-plugin-local-resolve';
import bundleSize from 'rollup-plugin-bundle-size';
import uglify from 'rollup-plugin-uglify';
import replace from 'rollup-plugin-replace'
import ignore from 'rollup-plugin-ignore'
import pkg from './package.json';
const cjs = {
exports: 'named',
format: 'cjs'
}
const es = {
format: 'es'
}
const getCJS = override => Object.assign({}, cjs, override)
const getESM = override => Object.assign({}, es, override)
const configBase = {
input: 'src/index.js',
plugins: [
localResolve(),
json(),
babel({
babelrc: false,
presets: [['es2015', { modules: false, loose: true }]],
plugins: ['transform-decorators-legacy', 'transform-class-properties', 'external-helpers'],
runtimeHelpers: true
}),
bundleSize()
],
external: ['restructure/src/utils'].concat(
Object.keys(pkg.dependencies)
)
}
const serverConfig = Object.assign({}, configBase, {
output: [
getESM({ file: 'dist/fontkit.es.js' }),
getCJS({ file: 'dist/fontkit.cjs.js' }),
],
plugins: configBase.plugins.concat(
replace({
BROWSER: JSON.stringify(false),
})
),
external: configBase.external.concat(['fs', 'brotli/decompress'])
})
const serverProdConfig = Object.assign({}, serverConfig, {
output: [
getESM({ file: 'dist/fontkit.es.min.js' }),
getCJS({ file: 'dist/fontkit.cjs.min.js' }),
],
plugins: serverConfig.plugins.concat(
uglify()
),
})
const browserConfig = Object.assign({}, configBase, {
output: [
getESM({ file: 'dist/fontkit.browser.es.js' }),
getCJS({ file: 'dist/fontkit.browser.cjs.js' }),
],
plugins: configBase.plugins.concat(
replace({
BROWSER: JSON.stringify(true),
}),
ignore(['fs', 'brotli', 'brotli/decompress', './WOFF2Font'])
)
})
const browserProdConfig = Object.assign({}, browserConfig, {
output: [
getESM({ file: 'dist/fontkit.browser.es.min.js' }),
getCJS({ file: 'dist/fontkit.browser.cjs.min.js' }),
],
plugins: browserConfig.plugins.concat(
uglify()
),
})
export default [
serverConfig,
serverProdConfig,
browserConfig,
browserProdConfig
]