-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
43 lines (36 loc) · 1.2 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
/**
* 静态文件打包
*/
var gulp = require('gulp');
var sass = require('gulp-ruby-sass');
var autoprefixer = require('gulp-autoprefixer');
var gulpUtil = require('gulp-util');
var webpack = require('webpack');
gulp.task('sass:build', function () {
return sass(__dirname + '/public/src/sass/**/*.scss', { style: 'compressed', noCache: true})
.on('error', function (err) {
console.error('Error!', err.message);
})
.pipe(autoprefixer())
.pipe(gulp.dest(__dirname + '/public/dist/css'));
});
var webpackConfig = require('./public/webpack.config');
var compiler = webpack(webpackConfig);
gulp.task('webpack:build', function () {
compiler.run(function (err, stats) {
if(err) throw new gutil.PluginError("webpack", err);
gulpUtil.log("[webpack]", stats.toString({
// output options
}));
});
});
gulp.task('webpack:watch', function () {
compiler.watch(200, function (err, stats) {
if(err) throw new gutil.PluginError("webpack", err);
});
});
gulp.task('default', ['sass:build', 'webpack:build'], function(){});
gulp.task('watch', function () {
gulp.watch('./public/src/sass/**/*.scss', ['sass:build']);
gulp.watch('./public/src/js/**/*.js', ['webpack:build']);
});