update code

This commit is contained in:
dengtongyu committed 2018-02-19 21:33:51 +08:00
1 parent fea0427a64
commit 4a6bbe93b2
3 files changed
+21 -1

No files matched your search

+1 -1
View File
@@ -74,7 +74,7 @@ function setPath(pathName) {
pathConfig.currPath = pathName;
//stylus build目录
pathConfig.styleBuildPath = config.base + '/pages/' + pathName + '/**/*.styl';
pathConfig.styleBuildPath = config.base + '/pages/' + pathName + '/**/!(_)*.styl';
//swig build目录
pathConfig.htmlBuildPath = config.base + '/pages/' + pathName + '/**/*.htm';
+2
View File
@@ -13,6 +13,8 @@
"browser-sync": "^2.18.11",
"gulp": "^3.9.1",
"gulp-htmlmin": "^3.0.0",
"gulp-notify": "^3.2.0",
"gulp-plumber": "^1.2.0",
"gulp-stylus": "^2.6.0",
"gulp-swig": "^0.8.0",
"gulp-tmod": "^2.0.3",
+18
View File
@@ -17,6 +17,8 @@ const reload = browserSync.reload;
const proxyMiddleware = require('http-proxy-middleware');
const lodash = require('lodash');
const path = require('path');
const plumber = require('gulp-plumber');
const notify = require('gulp-notify');
let swigOpts = {
defaults: {
@@ -25,6 +27,16 @@ let swigOpts = {
}
};
function onErrorHandler(err) {
notify.onError({
title: "Webpage",
subtitle: err.plugin + " error!",
message: "Error: <%= error.message %>",
sound: "Beep"
})(err);
this.emit('end');
}
//代理配置
let proxy = proxyMiddleware(
['/node_modules','/res/images/userimage'],
@@ -136,6 +148,7 @@ module.exports = function (pathConfig,config) {
//stylus任务
gulp.task('stylus_build', function () {
return gulp.src(pathConfig.styleBuildPath, config)
.pipe(plumber({errorHandler: onErrorHandler}))
.pipe(stylus({
compress: true
}))
@@ -146,6 +159,7 @@ module.exports = function (pathConfig,config) {
//swig任务
gulp.task('swig_build', function () {
return gulp.src(pathConfig.htmlBuildPath, config)
.pipe(plumber({errorHandler: onErrorHandler}))
.pipe(swig(swigOpts))
.pipe(gulp.dest(config.build))
.on("end", reload);
@@ -154,6 +168,7 @@ module.exports = function (pathConfig,config) {
//htmlmin任务
gulp.task('htmlmin_build', function () {
return gulp.src(pathConfig.htmlminBuildPath, config)
.pipe(plumber({errorHandler: onErrorHandler}))
.pipe(htmlmin({collapseWhitespace: true}))
.pipe(gulp.dest(config.build))
.on("end", reload);
@@ -162,6 +177,7 @@ module.exports = function (pathConfig,config) {
//webpack任务
gulp.task('webpack_build', function () {
return gulp.src(pathConfig.scriptBuildPath)
.pipe(plumber({errorHandler: onErrorHandler}))
.pipe(webpack( webPackConfig ))
.pipe(gulp.dest(pathConfig.webpackOutPath))
.on("end", reload);
@@ -170,6 +186,7 @@ module.exports = function (pathConfig,config) {
//uglify任务
gulp.task('uglify_build', function () {
return gulp.src(pathConfig.uglifyBuildPath, {base: config.build})
.pipe(plumber({errorHandler: onErrorHandler}))
.pipe(uglify())
.pipe(gulp.dest(config.build))
.on("end", reload);
@@ -179,6 +196,7 @@ module.exports = function (pathConfig,config) {
gulp.task('tmod_build', function () {
console.log(pathConfig.tmodBuildPath);
return gulp.src(pathConfig.tmodBuildPath)
.pipe(plumber({errorHandler: onErrorHandler}))
.pipe(tmodjs({
templateBase: pathConfig.tmodBasePath,
output: pathConfig.tmodOutPath,