forked from pedronauck/react-simpletabs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
50 lines (42 loc) · 1.33 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
'use strict';
var gulp = require('gulp'),
gutil = require('gulp-util'),
browserSync = require('browser-sync'),
webpack = require('webpack'),
webpackConfig = require('./webpack.config.js');
gulp.task('webpack', function(callback) {
var jsFilename = webpackConfig.output.filename;
var cssFilename = webpackConfig.plugins[1].filename;
if (gutil.env.production) {
webpackConfig.output.filename = gutil.replaceExtension(jsFilename, '.min.js');
webpackConfig.plugins[1].filename = gutil.replaceExtension(cssFilename, '.min.css');
webpackConfig.plugins = webpackConfig.plugins.concat(
new webpack.DefinePlugin({
'process.env': { 'NODE_ENV': JSON.stringify('production') }
}),
new webpack.optimize.DedupePlugin(),
new webpack.optimize.UglifyJsPlugin()
);
}
webpack(webpackConfig).run(function(err, stats) {
if (err) {
throw new gutil.PluginError('webpack', err);
}
gutil.log('[webpack]', stats.toString({ colors: true }));
browserSync.reload();
callback();
});
});
gulp.task('server', function() {
browserSync({
open: false,
notify: false,
server: {
baseDir: ['example', 'dist']
}
});
});
gulp.task('watch', function() {
gulp.watch('./lib/**/*.{css,jsx}', ['webpack']);
});
gulp.task('default', ['webpack', 'server', 'watch']);