forked from moltin/js-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrollup.config.js
75 lines (71 loc) · 1.73 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
import babel from 'rollup-plugin-babel'
import { uglify } from 'rollup-plugin-uglify'
import resolve from 'rollup-plugin-node-resolve'
import commonjs from 'rollup-plugin-commonjs'
import json from 'rollup-plugin-json'
import serve from 'rollup-plugin-serve'
import livereload from 'rollup-plugin-livereload'
import filesize from 'rollup-plugin-filesize'
import pkg from './package.json'
const { NODE_ENV = 'development' } = process.env
const isProd = NODE_ENV === 'production'
const isDev = NODE_ENV === 'development' && process.env.SERVE === 'true'
const baseConfig = {
input: 'src/moltin.js',
watch: {
include: 'src/**'
},
external: ['es6-promise', 'fetch-everywhere'],
plugins: [
json(),
babel({
exclude: ['package.json', '**/node_modules/**'],
presets: [
['@babel/preset-env', { modules: false }],
'@babel/preset-stage-3'
]
}),
filesize()
]
}
export default [
{
...baseConfig,
output: {
name: 'moltin',
exports: 'named',
file: pkg.browser,
format: 'umd'
},
plugins: [
...baseConfig.plugins,
resolve({ browser: true }),
commonjs(),
isProd &&
uglify({
compress: {
warnings: false
}
}),
isDev && serve({ contentBase: ['dist', 'examples'], open: true }),
isDev && livereload()
].filter(Boolean)
},
{
...baseConfig,
output: {
file: pkg['cjs:main'],
format: 'cjs',
exports: 'named'
},
external: [...baseConfig.external, ...Object.keys(pkg.dependencies || {})]
},
{
...baseConfig,
output: {
file: pkg.module,
format: 'es'
},
external: [...baseConfig.external, ...Object.keys(pkg.dependencies || {})]
}
]