forked from jaames/iro.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.js
98 lines (95 loc) · 2.57 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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
import { version } from './package.json';
import alias from '@rollup/plugin-alias';
import buble from '@rollup/plugin-buble';
import nodeResolve from '@rollup/plugin-node-resolve';
import replace from '@rollup/plugin-replace';
import typescript from 'rollup-plugin-typescript2';
import { uglify } from 'rollup-plugin-uglify';
import serve from 'rollup-plugin-serve';
import livereload from 'rollup-plugin-livereload';
import bundleSize from 'rollup-plugin-bundle-size';
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 = `/*!
* iro.js v${version}
* 2016-2021 James Daniel
* Licensed under MPL 2.0
* github.com/jaames/iro.js
*/
`
module.exports = {
input: 'src/index.ts',
output: [
esmodule ? {
file: 'dist/iro.es.js',
format: 'es',
name: 'iro',
banner: banner,
sourcemap: devserver ? true : false,
sourcemapFile: 'dist/iro.es.map'
} : {
file: prod ? 'dist/iro.min.js' : 'dist/iro.js',
format: 'umd',
name: 'iro',
banner: banner,
sourcemap: devserver ? true : false,
sourcemapFile: prod ? 'dist/iro.min.js.map' : 'dist/iro.js.map'
}
].filter(Boolean),
plugins: [
bundleSize(),
nodeResolve(),
alias({
resolve: ['.jsx', '.js'],
}),
replace({
VERSION: JSON.stringify(version),
PROD: prod ? 'true' : 'false',
DEV_SERVER: devserver ? 'true' : 'false'
}),
typescript({
abortOnError: false,
typescript: require('typescript'),
tsconfigOverride: {
compilerOptions: {
module: 'esnext',
target: 'esnext',
declaration: !devserver ? true : false,
sourceMap: devserver ? true : false
},
},
}),
buble({
extensions: ['.js', '.jsx', '.ts', '.tsx'],
jsx: 'h',
objectAssign: 'Object.assign',
transforms: {}
}),
// commonjs(),
devserver ? serve({
contentBase: ['dist', 'demo']
}) : false,
devserver ? livereload({
watch: 'dist'
}) : false,
// only minify if we're producing a non-es production build
prod && !esmodule ? uglify({
mangle: {
properties: {
regex: /^_/
},
},
output: {
comments: function(node, comment) {
if (comment.type === 'comment2') {
// preserve banner comment
return /\!/i.test(comment.value);
}
return false;
}
}
}) : false,
].filter(Boolean)
};