-
Notifications
You must be signed in to change notification settings - Fork 18
/
rollup.config.js
68 lines (60 loc) · 1.5 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
import {writeFileSync} from 'fs'
import {nodeResolve} from '@rollup/plugin-node-resolve'
import commonjs from '@rollup/plugin-commonjs'
import sourceMaps from 'rollup-plugin-sourcemaps'
import {terser} from 'rollup-plugin-terser'
import gzip from 'rollup-plugin-gzip'
import ts from '@wessberg/rollup-plugin-ts'
import sass from 'rollup-plugin-sass'
import copy from 'rollup-plugin-copy'
const pkg = require('./package.json')
const isProductionBuild = process.env.NODE_ENV === 'production'
let plugins = [
nodeResolve(),
commonjs(),
ts(),
sass({
output: (styles) => {
writeFileSync('dist/index.css', `@charset "UTF-8"; ${styles}`)
},
options: {
outputStyle: isProductionBuild ? 'compressed' : 'expanded',
},
}),
copy({
targets: [
{src: 'src/Styles/Fonts', dest: 'dist'},
{src: 'src/Styles/variables.scss', dest: 'dist'},
{src: 'src/**/Images/*', dest: 'dist/Images'},
],
}),
sourceMaps(),
]
// Minify and compress output when in production
if (isProductionBuild) {
plugins = [...plugins, terser(), gzip()]
}
const input = 'src/index.ts'
const globals = {
react: 'React',
'react-dom': 'ReactDOM',
uuid: 'uuid',
lodash: '_',
'prop-types': 'PropTypes',
}
// Do not bundle peer dependencies
const external = ['react', 'react-dom', 'lodash', 'uuid', 'prop-types']
export default [
{
input,
plugins,
external,
output: {
name: pkg.name,
file: pkg.main,
format: 'umd',
sourcemap: true,
globals,
},
},
]