This repository was archived by the owner on Apr 22, 2021. It is now read-only.
forked from foliojs/png.js
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathrollup.config.js
More file actions
82 lines (73 loc) · 1.75 KB
/
rollup.config.js
File metadata and controls
82 lines (73 loc) · 1.75 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
81
82
import babel from 'rollup-plugin-babel';
import uglify from 'rollup-plugin-uglify';
import replace from 'rollup-plugin-replace'
import ignore from 'rollup-plugin-ignore'
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: [
babel({
babelrc: false,
presets: [['es2015', { modules: false }]],
plugins: ['external-helpers'],
runtimeHelpers: true
})
],
}
const serverConfig = Object.assign({}, configBase, {
output: [
getESM({ file: 'dist/png-js.es.js' }),
getCJS({ file: 'dist/png-js.cjs.js' }),
],
plugins: configBase.plugins.concat(
replace({
BROWSER: JSON.stringify(false),
})
),
external: ['fs']
})
const serverProdConfig = Object.assign({}, serverConfig, {
output: [
getESM({ file: 'dist/png-js.es.min.js' }),
getCJS({ file: 'dist/png-js.cjs.min.js' }),
],
plugins: serverConfig.plugins.concat(
uglify()
),
})
const browserConfig = Object.assign({}, configBase, {
output: [
getESM({ file: 'dist/png-js.browser.es.js' }),
getCJS({ file: 'dist/png-js.browser.cjs.js' }),
],
plugins: configBase.plugins.concat(
replace({
BROWSER: JSON.stringify(true),
"png-js": "png-js/png.js"
}),
ignore(['fs'])
)
})
const browserProdConfig = Object.assign({}, browserConfig, {
output: [
getESM({ file: 'dist/png-js.browser.es.min.js' }),
getCJS({ file: 'dist/png-js.browser.cjs.min.js' }),
],
plugins: browserConfig.plugins.concat(
uglify()
),
})
export default [
serverConfig,
serverProdConfig,
browserConfig,
browserProdConfig
]