-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathrollup.config.js
57 lines (50 loc) · 1.18 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
/* eslint-env node */
import pkg from './package.json';
import babel from 'rollup-plugin-babel';
import replace from 'rollup-plugin-replace';
import uglify from 'rollup-plugin-uglify';
const minify = process.env.NODE_ENV === 'production';
const banner = `/**
* ${pkg.name} - ${pkg.description}
* @version v${pkg.version}
* @link ${pkg.homepage}
* @license ${pkg.license}
**/
`;
const [ filename ] = pkg.main.split( '/' ).reverse();
let name = filename.replace( '.js', '' );
const file = minify ? pkg.main.replace( '.js', '.min.js' ) : pkg.main;
const plugins = [
replace({
'Array.from': 'Array.prototype.slice.call'
}),
babel({
exclude: 'node_modules/**'
})
];
name = name.charAt( 0 ).toUpperCase() + name.slice( 1 );
if( minify ){
plugins.push( uglify({
output: {
'comments': ( node, comment ) => {
const text = comment.value,
type = comment.type;
if ( type === 'comment2' ) {
// multiline comment
return /@preserve|@license|@cc_on/i.test( text );
}
}
}
}));
}
export default {
input: pkg.module,
output: {
banner,
file,
format: 'umd',
indent: ' ',
name
},
plugins
};