-
Notifications
You must be signed in to change notification settings - Fork 10
/
rollup.config.js
81 lines (78 loc) · 2.17 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
import { version, description } from './package.json';
import filesize from 'rollup-plugin-filesize';
import buble from 'rollup-plugin-buble';
import alias from 'rollup-plugin-alias';
import commonjs from 'rollup-plugin-commonjs';
import nodeResolve from 'rollup-plugin-node-resolve';
import replace from 'rollup-plugin-replace';
import { uglify } from 'rollup-plugin-uglify';
import serve from 'rollup-plugin-serve';
import livereload from 'rollup-plugin-livereload';
const build = process.env.BUILD || "development";
const devserver = process.env.DEV_SERVER || false;
const esmodule = process.env.ES_MODULE || false;
const prod = build === "production";
const banner = `/*!
* Zfont v${version}
* ${description}
* 2019 James Daniel
* MIT Licensed
* github.com/jaames/zfont
*/
`
module.exports = {
input: 'src/index.js',
output: [
esmodule ? {
file: 'dist/zfont.es.js',
format: 'es',
name: 'Zfont',
banner: banner,
sourcemap: true,
sourcemapFile: 'dist/zfont.es.map'
} : {
file: prod ? 'dist/zfont.min.js' : 'dist/zfont.js',
format: 'umd',
name: 'Zfont',
banner: banner,
sourcemap: true,
sourcemapFile: prod ? 'dist/zfont.min.js.map' : 'dist/zfont.js.map'
}
].filter(Boolean),
plugins: [
alias({
resolve: ['.jsx', '.js']
}),
replace({
VERSION: JSON.stringify(version),
PROD: prod ? 'true' : 'false',
DEV_SERVER: devserver ? 'true' : 'false'
}),
buble({
jsx: 'h',
objectAssign: 'Object.assign',
transforms: {
}
}),
nodeResolve(),
commonjs(),
!prod && devserver ? serve({
contentBase: ['dist', 'demo']
}) : false,
!prod && devserver ? livereload() : false,
// show filesize stats when building dist files
!devserver ? filesize() : false,
// only minify if we're producing a non-es production build
prod && !esmodule ? uglify({
output: {
comments: function(node, comment) {
if (comment.type === 'comment2') {
// preserve banner comment
return /\!/i.test(comment.value);
}
return false;
}
}
}) : false,
].filter(Boolean)
};