-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
71 lines (56 loc) · 1.72 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
59
60
61
62
63
64
65
66
67
68
69
70
71
'use strict';
var gulp = require('gulp');
var webpack = require("webpack");
var WebpackDevServer = require("webpack-dev-server");
var webpackConfig = require("./webpack.config.js");
var stream = require('webpack-stream');
var wiredep = require('wiredep').stream;
// Get Config
var config = require('./config.js');
// Load plugins
var $ = require('gulp-load-plugins')();
gulp.task('webpack', [], function() {
return gulp.src(config.allIn)
.pipe($.sourcemaps.init())
.pipe(stream(webpackConfig))
.pipe($.sourcemaps.write())
.pipe(gulp.dest(config.out));
});
gulp.task("webpack-dev-server", function(callback) {
// modify some webpack config options
var myConfig = Object.create(webpackConfig);
myConfig.devtool = "eval";
myConfig.debug = true;
// Start a webpack-dev-server
new WebpackDevServer(webpack(myConfig), {
//publicPath: "/",
contentBase: config.out,
stats: {
colors: true
}
}).listen(8080, "localhost", function(err) {
if (err) throw new $.util.PluginError("webpack-dev-server", err);
$.util.log("[webpack-dev-server]", "http://localhost:8080/webpack-dev-server/index.html");
});
});
gulp.task('clean', function () {
return gulp.src(config.allOut, { read: false }).pipe($.clean());
});
gulp.task('html', function () {
return gulp.src(config.index)
.pipe($.useref())
.pipe(gulp.dest(config.out));
});
gulp.task('assets', function () {
return gulp.src(config.assets)
.pipe(gulp.dest(config.out));
});
gulp.task('watch', function() {
gulp.watch(config.all, ['build']);
});
gulp.task('build', function () {
gulp.start(['html', 'assets', 'webpack']);
});
gulp.task('default', ['clean'], function () {
gulp.start(['webpack-dev-server', 'watch', 'build']);
});