-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrollup.config.js
43 lines (35 loc) · 1.07 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
/* eslint-env-node */
import babel from 'rollup-plugin-babel';
import uglify from 'rollup-plugin-uglify';
import filesize from 'rollup-plugin-filesize';
import path from 'path';
const pkg = require(path.join(process.cwd(), 'package.json')); // eslint-disable-line
const isProduction = process.env.BUILD === 'production';
const hasName = process.argv.indexOf('--name') + 1 || process.argv.indexOf('-n') + 1;
const name = hasName ? process.argv[hasName] : 'litequery';
const fileName = name.replace(/([A-Z])/g, (m, s) => `-${s.toLowerCase()}`);
const format = 'umd';
const config = {
name,
input: 'src/index.js',
output: {
file: `dist/${fileName}.js`,
format
},
format, // Needed for rollup-plugin-uglify
sourcemap: !isProduction,
plugins: [
babel({
exclude: 'node_modules/**',
presets: [['es2015', { modules: false }]],
plugins: ['external-helpers'],
babelrc: false
}),
filesize()
]
};
if (isProduction) {
config.dest = config.output.file.replace(/js$/, 'min.js');
config.plugins.push(uglify());
}
export default config;