-
Notifications
You must be signed in to change notification settings - Fork 139
/
gulpfile.js
58 lines (48 loc) · 1.58 KB
/
gulpfile.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
52
53
54
55
56
57
58
var es = require('event-stream');
var fs = require('fs');
var open = require('open');
var strftime = require('strftime');
var buffer = require('gulp-buffer');
var gulpWebpack = require('gulp-webpack');
var gulp = require('gulp');
var gutil = require('gulp-util');
var header = require('gulp-header');
var webpack = require('webpack');
var webpackDevServer = require('webpack-dev-server');
var date = strftime('%F');
var port = 2992;
var version = require('./package.json').version;
var webpackConfig = require('./webpack.config.base.js');
gulp.task('dist', function() {
var banner = fs.readFileSync('./js/banner/copyright.js');
var bannerMin = fs.readFileSync('./js/banner/copyright.min.js');
var opts = {
date: date,
version: version
};
var uncompressed = gulp.src('./index.js')
.pipe(gulpWebpack(webpackConfig()))
.pipe(buffer())
.pipe(header(banner, opts))
.pipe(gulp.dest('./'));
var minified = gulp.src('./index.js')
.pipe(gulpWebpack(webpackConfig({minify: true})))
.pipe(buffer())
.pipe(header(bannerMin, opts))
.pipe(gulp.dest('./'));
return es.concat(uncompressed, minified);
});
gulp.task('test', function() {
var devWebpackConfig = webpackConfig({dev: true});
new webpackDevServer(webpack(devWebpackConfig), {
contentBase: 'test/',
stats: {
color: true
}
}).listen(port, 'localhost', function(err) {
if(err) throw new gutil.PluginError("Isomer", err);
});
open('http://localhost:' + port + '/webpack-dev-server/')
gutil.log('[Isomer]', 'listening on http://localhost:' + port);
});
gulp.task('default', ['dist'])