-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.js
45 lines (38 loc) · 1.22 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
/* global process __dirname */
import buble from 'rollup-plugin-buble';
import resolve from 'rollup-plugin-node-resolve';
import commonjs from 'rollup-plugin-commonjs';
import uglify from 'rollup-plugin-uglify';
import fs from 'fs';
import path from 'path';
const inputFolder = './src/javascripts';
// Get all .js files from input folder
const entries = fs.readdirSync(path.resolve(__dirname, inputFolder)).map((fileName) => {
return fileName.match(/.js$/) ? `${ inputFolder }/${ fileName }` : undefined;
}).filter(f => !!f);
export default entries.map((filename) => ({
input: filename,
output: {
dir: `./${ process.env.npm_package_config_output }/assets/javascripts`,
format: 'iife',
// format: 'es',
sourcemap: true
},
plugins: [
buble({
objectAssign: 'Object.assign'
}),
resolve({
preferBuiltins: false,
mainFields: ['jsnext', 'main', 'browser'],
// jsnext: true,
// browser: true,
// main: true
}),
commonjs({
include: 'node_modules/**',
sourceMap: false
}),
process.env.NODE_ENV === 'production' ? uglify.uglify() : null
]
}));