-
Notifications
You must be signed in to change notification settings - Fork 57
/
rollup.config.mjs
66 lines (61 loc) · 1.73 KB
/
rollup.config.mjs
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
// Libs
import babel from 'rollup-plugin-babel';
import commonjs from 'rollup-plugin-commonjs';
import gzip from 'rollup-plugin-gzip';
import nodeResolve from 'rollup-plugin-node-resolve';
import path from 'path';
import pkgConfig from './package.json' assert { type: 'json' };
import { uglify } from 'rollup-plugin-uglify';
import { optimizeLodashImports } from '@optimize-lodash/rollup-plugin';
// Constants
const DIST = process.env.DIST || false;
const MIN = process.env.MIN || false;
const banner = `/* Inspire Tree
* @version ${pkgConfig.version}
* ${pkgConfig.repository}
* @copyright Copyright 2015 Helion3, and other contributors
* @license Licensed under MIT
* see ${pkgConfig.repository}/blob/master/LICENSE
*/`;
const plugins = [
optimizeLodashImports(),
babel({
exclude: 'node_modules/**'
}),
nodeResolve({
browser: true
}),
commonjs({
sourceMap: false,
namedExports: {
'node_modules/es6-promise/dist/es6-promise.js': ['Promise'],
'node_modules/eventemitter2/lib/eventemitter2.js': ['EventEmitter2']
}
})
];
if (MIN) {
plugins.push(uglify({
output: {
comments: /@license/
}
}));
plugins.push(gzip());
}
export default {
input: path.join('src', 'tree.js'),
external: [/^lodash/],
plugins: plugins,
output: {
file: path.join(DIST ? 'dist' : 'build', 'inspire-tree' + (MIN ? '.min' : '') + '.js'),
format: 'umd',
name: 'InspireTree',
banner: banner,
globals: (name) => {
const [, fnc] = name.match(/^lodash\/(.*)\.js$/i) || []
if (!fnc) {
return name
}
return `_.${fnc}`
}
}
};