forked from getgrav/grav-plugin-form
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
53 lines (46 loc) · 1.41 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
'use strict';
var gulp = require('gulp'),
util = require('util'),
path = require('path'),
immutable = require('immutable'),
gulpWebpack = require('gulp-webpack'),
webpack = require('webpack'),
sourcemaps = require('gulp-sourcemaps'),
exec = require('child_process').execSync,
pwd = exec('pwd').toString();
var plugins = {},
base = immutable.fromJS(require('./webpack.conf.js')),
options = {
prod: base.mergeDeep({
devtool: 'source-map',
plugins: [
new webpack.DefinePlugin({
'process.env': { NODE_ENV: '"production"' }
}),
new webpack.optimize.UglifyJsPlugin({
sourceMap: true,
compress: {
warnings: false
}
}),
new webpack.ProvidePlugin(plugins)
],
output: {
filename: 'form.min.js'
}
})
};
var compileJS = function(watch) {
var prodOpts = options.prod.set('watch', watch);
return gulp.src('app/main.js')
.pipe(gulpWebpack(prodOpts.toJS()))
.pipe(gulp.dest('assets/'));
};
gulp.task('js', function() {
compileJS(false);
});
gulp.task('watch', function() {
compileJS(true);
});
gulp.task('all', ['js']);
gulp.task('default', ['all']);