This repository has been archived by the owner on Jul 24, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 77
/
rollup.config.js
83 lines (78 loc) · 2.11 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
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 dts from 'rollup-plugin-dts'
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(), filesize()]
}
const babelRollupPlugin = babel({
babelHelpers: 'bundled',
exclude: ['package.json', 'node_modules/**']
})
export default [
{
...baseConfig,
output: {
name: 'moltin',
exports: 'named',
file: pkg.browser,
format: 'umd'
},
plugins: [
...baseConfig.plugins,
resolve({ browser: true }),
commonjs(),
/*
babel plugin should be placed after commonjs
https://github.com/rollup/plugins/tree/master/packages/babel#using-with-rollupplugin-commonjs
*/
babelRollupPlugin,
isProd &&
uglify({
compress: {
warnings: false
}
}),
isDev && serve({ contentBase: ['dist', 'examples'], open: true }),
isDev && livereload()
].filter(Boolean)
},
{
...baseConfig,
plugins: [...baseConfig.plugins, babelRollupPlugin],
output: {
file: pkg['cjs:main'],
format: 'cjs',
exports: 'named'
},
external: [...baseConfig.external, ...Object.keys(pkg.dependencies || {})]
},
{
...baseConfig,
plugins: [...baseConfig.plugins, babelRollupPlugin],
output: {
file: pkg.module,
format: 'es'
},
external: [...baseConfig.external, ...Object.keys(pkg.dependencies || {})]
},
{
input: 'src/moltin.d.ts',
output: [{ file: 'dist/moltin.d.ts', format: 'es' }],
plugins: [dts()]
}
]