-
Notifications
You must be signed in to change notification settings - Fork 21
/
build.js
51 lines (48 loc) · 1.13 KB
/
build.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
'use strict';
const babel = require('rollup-plugin-babel');
const rollup = require('rollup');
const commonjs = require('rollup-plugin-commonjs');
const nodeResolve = require('rollup-plugin-node-resolve');
const glob = require('glob-all');
function generateFileList(options) {
return {
resolveId(id) {
if (id === options.id) {
return id;
}
},
load(id) {
if (id === options.id) {
// Pass in relative filepaths to glob, then convert to appropriate URLs
const files = glob.sync(options.patterns)
.map(file => file.replace('public/', '/'));
return `export default ${JSON.stringify(files)};`;
}
}
}
}
rollup.rollup({
entry: 'src/index.js',
plugins: [
nodeResolve({ jsnext: true, main: true }),
commonjs({
include: 'node_modules/**'
}),
babel({
exclude: 'node_modules/**'
}),
generateFileList({
id: '\0emoji-images',
patterns: [
'public/images/emoji/*.svg'
]
})
]
}).then(bundle => {
bundle.write({
format: 'umd',
dest: 'public/build/bundle.js'
})
}).catch(err => {
console.error(err);
});