-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgulpfile.js
More file actions
73 lines (61 loc) · 2.02 KB
/
gulpfile.js
File metadata and controls
73 lines (61 loc) · 2.02 KB
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
var gulp = require("gulp");
var gutil = require("gulp-util");
var webpack = require("webpack");
var webpackConfig = require("./webpack.config.js");
var execSync = require('child_process').execSync;
var bootstrap = function() {
gutil.log("bootstrapping");
execSync('php bootstrap.php');
}
gulp.task("default", ["webpack:build-dev"], function() {
gulp.watch(["admin/assets/**/*"], ["webpack:build-dev"]);
// gulp.watch([
// "src/assets/css/**/*",
// "admin/assets/css/**/*"], [""])
});
// Production build
gulp.task("build", ["webpack:build"]);
gulp.task("webpack:build", function(callback) {
// modify some webpack config options
var myConfig = Object.create(webpackConfig).map(function(config) {
config.plugins = config.plugins.concat(
new webpack.DefinePlugin({
"process.env": {
// This has effect on the react lib size
"NODE_ENV": JSON.stringify("production")
}
}),
new webpack.optimize.DedupePlugin(),
new webpack.optimize.UglifyJsPlugin()
);
return config;
});
// run webpack
webpack(myConfig, function(err, stats) {
if(err) throw new gutil.PluginError("webpack:build", err);
gutil.log("[webpack:build]", stats.toString({
colors: true
}));
bootstrap();
callback();
});
});
// modify some webpack config options
var myDevConfig = Object.create(webpackConfig).map(function(config) {
config.devtool = "sourcemap";
config.debug = true;
return config;
});
// create a single instance of the compiler to allow caching
var devCompiler = webpack(myDevConfig);
gulp.task("webpack:build-dev", function(callback) {
// run webpack
devCompiler.run(function(err, stats) {
if(err) throw new gutil.PluginError("webpack:build-dev", err);
gutil.log("[webpack:build-dev]", stats.toString({
colors: true
}));
bootstrap();
callback();
});
});