forked from ui-router/core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrollup.config.js
55 lines (45 loc) · 1.42 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
import nodeResolve from 'rollup-plugin-node-resolve';
import uglify from 'rollup-plugin-uglify';
import progress from 'rollup-plugin-progress';
import sourcemaps from 'rollup-plugin-sourcemaps';
import visualizer from 'rollup-plugin-visualizer';
const MINIFY = process.env.MINIFY;
const pkg = require('./package.json');
const banner =
`/**
* ${pkg.description}
* @version v${pkg.version}
* @link ${pkg.homepage}
* @license MIT License, http://www.opensource.org/licenses/MIT
*/`;
const uglifyOpts = { output: {} };
// retain multiline comment with @license
uglifyOpts.output.comments = (node, comment) =>
comment.type === 'comment2' && /@license/i.test(comment.value);
const onwarn = (warning) => {
// Suppress this error message... https://github.com/rollup/rollup/wiki/Troubleshooting#this-is-undefined
const ignores = ['THIS_IS_UNDEFINED'];
if (!ignores.some(code => code === warning.code)) {
console.error(warning.message);
}
};
const plugins = [
nodeResolve({jsnext: true}),
progress({ clearLine: false }),
sourcemaps(),
visualizer({ sourcemap: true }),
];
if (MINIFY) plugins.push(uglify(uglifyOpts));
const extension = MINIFY ? ".min.js" : ".js";
const CONFIG = {
moduleName: '@uirouter/core',
entry: 'lib-esm/index.js',
dest: '_bundles/ui-router-core' + extension,
sourceMap: true,
format: 'umd',
exports: 'named',
plugins: plugins,
banner: banner,
onwarn: onwarn,
};
export default CONFIG;