-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathgulpfile.js
57 lines (49 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
51
52
53
54
55
56
57
const gulp = require('gulp');
const gutil = require('gulp-util');
const webpack = require('webpack');
const webpackConfigBase = require('./webpack/webpack-base.config');
const webpackConfigDev = require('./webpack/webpack-dev.config');
const path = require('path');
const del = require('del');
const fs = require('fs');
const webpackStatsDev = {
hash: true,
version: true,
timings: true,
assets: true,
chunks: false,
chunkModules: false,
modules: false,
cached: false,
reasons: true,
source: true,
errorDetails: true,
chunkOrigins: false,
colors: true,
};
function deployToPath(destinationPath) {
gulp.src('./dist/**')
.pipe(gulp.dest(destinationPath));
}
gulp.task('clean', () => del(['./dist/**']));
gulp.task('dev', ['clean', 'webpack-dev']);
gulp.task('webpack-dev', (callback) => {
webpack(webpackConfigDev(webpackConfigBase), (err, stats) => {
if (err) {
throw new gutil.PluginError('webpack', err);
}
fs.writeFileSync(
path.join(__dirname, 'stats.json'),
JSON.stringify(stats.toJson('verbose')));
let deployPath;
process.argv.forEach((value, index, map) => {
if (value === '-path') {
deployPath = map[index + 1];
}
});
if (deployPath) {
deployToPath(deployPath);
}
gutil.log('[webpack]', stats.toString(webpackStatsDev));
});
});