-
Notifications
You must be signed in to change notification settings - Fork 63
/
stop.js
42 lines (36 loc) · 1.36 KB
/
stop.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
'use strict';
var url = require('url');
var fs = require('fs');
var stop = require('stop');
var promiseVersion = require('./package.json').dependencies.promise;
var server = require('./server.js');
stop.getWebsiteStream('http://localhost:3000', {
filter: function (currentURL) {
return url.parse(currentURL).hostname === 'localhost';
},
parallel: 1
})
.syphon(stop.addFavicon())
.syphon(stop.minifyJS({filter: function (url) {
console.dir(url);
return url.indexOf('static') !== -1;
}}))
.syphon(stop.minifyCSS({deadCode: true, ignore: ['carbon'], silent: true}))
.syphon(stop.addManifest('/app.manifest', {addLinks: true}))
.syphon(stop.log())
.syphon(stop.checkStatusCodes([200]))
.syphon(stop.writeFileSystem(__dirname + '/out'))
.wait().done(function () {
server.close();
// todo: support source maps properly
copy('/polyfills/output/promise-' + promiseVersion + '.js.map',
'/out/polyfills/promise-' + promiseVersion + '.js.map');
copy('/polyfills/output/promise-' + promiseVersion + '.min.js.map',
'/out/polyfills/promise-' + promiseVersion + '.min.js.map');
copy('/polyfills/output/promise-done-' + promiseVersion + '.min.js.map',
'/out/polyfills/promise-done-' + promiseVersion + '.min.js.map');
function copy(src, dest) {
fs.writeFileSync(__dirname + dest, fs.readFileSync(__dirname + src));
}
console.log('success');
});