-
Notifications
You must be signed in to change notification settings - Fork 58
Expand file tree
/
Copy pathbuild.js
More file actions
25 lines (20 loc) · 766 Bytes
/
build.js
File metadata and controls
25 lines (20 loc) · 766 Bytes
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
/* global rm, mkdir, exec, ls*/
require('shelljs/global');
var fs = require('fs');
console.log('Cleaning output directory "dist/"...');
rm('-rf', 'dist');
mkdir('-p', 'dist');
console.log('Bundling all the things...');
exec('webpack --output-file \'bundle.[hash].js\' --devtool source-map --colors --progress');
function getBundleFilename() {
var matches = ls('dist/bundle.*.js');
if (!(matches && matches.length)) {
throw new Error('Expected to find "dist/bundle.[hash].js"');
}
return matches[0].replace('dist/', '');
}
console.log('Copying "index.html"...');
var indexHtml = fs.readFileSync('index.html', 'utf8');
indexHtml = indexHtml.replace('bundle.js', getBundleFilename());
indexHtml.to('dist/index.html');
console.log('Build successfull');