update code
This commit is contained in:
1 parent
fea0427a64
commit
4a6bbe93b2
3 files changed
+21
-1
No files matched your search
+1
-1
@@ -74,7 +74,7 @@ function setPath(pathName) {
|
|||||||
pathConfig.currPath = pathName;
|
pathConfig.currPath = pathName;
|
||||||
|
|
||||||
//stylus build目录
|
//stylus build目录
|
||||||
pathConfig.styleBuildPath = config.base + '/pages/' + pathName + '/**/*.styl';
|
pathConfig.styleBuildPath = config.base + '/pages/' + pathName + '/**/!(_)*.styl';
|
||||||
|
|
||||||
//swig build目录
|
//swig build目录
|
||||||
pathConfig.htmlBuildPath = config.base + '/pages/' + pathName + '/**/*.htm';
|
pathConfig.htmlBuildPath = config.base + '/pages/' + pathName + '/**/*.htm';
|
||||||
|
|||||||
@@ -13,6 +13,8 @@
|
|||||||
"browser-sync": "^2.18.11",
|
"browser-sync": "^2.18.11",
|
||||||
"gulp": "^3.9.1",
|
"gulp": "^3.9.1",
|
||||||
"gulp-htmlmin": "^3.0.0",
|
"gulp-htmlmin": "^3.0.0",
|
||||||
|
"gulp-notify": "^3.2.0",
|
||||||
|
"gulp-plumber": "^1.2.0",
|
||||||
"gulp-stylus": "^2.6.0",
|
"gulp-stylus": "^2.6.0",
|
||||||
"gulp-swig": "^0.8.0",
|
"gulp-swig": "^0.8.0",
|
||||||
"gulp-tmod": "^2.0.3",
|
"gulp-tmod": "^2.0.3",
|
||||||
|
|||||||
@@ -17,6 +17,8 @@ const reload = browserSync.reload;
|
|||||||
const proxyMiddleware = require('http-proxy-middleware');
|
const proxyMiddleware = require('http-proxy-middleware');
|
||||||
const lodash = require('lodash');
|
const lodash = require('lodash');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
|
const plumber = require('gulp-plumber');
|
||||||
|
const notify = require('gulp-notify');
|
||||||
|
|
||||||
let swigOpts = {
|
let swigOpts = {
|
||||||
defaults: {
|
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(
|
let proxy = proxyMiddleware(
|
||||||
['/node_modules','/res/images/userimage'],
|
['/node_modules','/res/images/userimage'],
|
||||||
@@ -136,6 +148,7 @@ module.exports = function (pathConfig,config) {
|
|||||||
//stylus任务
|
//stylus任务
|
||||||
gulp.task('stylus_build', function () {
|
gulp.task('stylus_build', function () {
|
||||||
return gulp.src(pathConfig.styleBuildPath, config)
|
return gulp.src(pathConfig.styleBuildPath, config)
|
||||||
|
.pipe(plumber({errorHandler: onErrorHandler}))
|
||||||
.pipe(stylus({
|
.pipe(stylus({
|
||||||
compress: true
|
compress: true
|
||||||
}))
|
}))
|
||||||
@@ -146,6 +159,7 @@ module.exports = function (pathConfig,config) {
|
|||||||
//swig任务
|
//swig任务
|
||||||
gulp.task('swig_build', function () {
|
gulp.task('swig_build', function () {
|
||||||
return gulp.src(pathConfig.htmlBuildPath, config)
|
return gulp.src(pathConfig.htmlBuildPath, config)
|
||||||
|
.pipe(plumber({errorHandler: onErrorHandler}))
|
||||||
.pipe(swig(swigOpts))
|
.pipe(swig(swigOpts))
|
||||||
.pipe(gulp.dest(config.build))
|
.pipe(gulp.dest(config.build))
|
||||||
.on("end", reload);
|
.on("end", reload);
|
||||||
@@ -154,6 +168,7 @@ module.exports = function (pathConfig,config) {
|
|||||||
//htmlmin任务
|
//htmlmin任务
|
||||||
gulp.task('htmlmin_build', function () {
|
gulp.task('htmlmin_build', function () {
|
||||||
return gulp.src(pathConfig.htmlminBuildPath, config)
|
return gulp.src(pathConfig.htmlminBuildPath, config)
|
||||||
|
.pipe(plumber({errorHandler: onErrorHandler}))
|
||||||
.pipe(htmlmin({collapseWhitespace: true}))
|
.pipe(htmlmin({collapseWhitespace: true}))
|
||||||
.pipe(gulp.dest(config.build))
|
.pipe(gulp.dest(config.build))
|
||||||
.on("end", reload);
|
.on("end", reload);
|
||||||
@@ -162,6 +177,7 @@ module.exports = function (pathConfig,config) {
|
|||||||
//webpack任务
|
//webpack任务
|
||||||
gulp.task('webpack_build', function () {
|
gulp.task('webpack_build', function () {
|
||||||
return gulp.src(pathConfig.scriptBuildPath)
|
return gulp.src(pathConfig.scriptBuildPath)
|
||||||
|
.pipe(plumber({errorHandler: onErrorHandler}))
|
||||||
.pipe(webpack( webPackConfig ))
|
.pipe(webpack( webPackConfig ))
|
||||||
.pipe(gulp.dest(pathConfig.webpackOutPath))
|
.pipe(gulp.dest(pathConfig.webpackOutPath))
|
||||||
.on("end", reload);
|
.on("end", reload);
|
||||||
@@ -170,6 +186,7 @@ module.exports = function (pathConfig,config) {
|
|||||||
//uglify任务
|
//uglify任务
|
||||||
gulp.task('uglify_build', function () {
|
gulp.task('uglify_build', function () {
|
||||||
return gulp.src(pathConfig.uglifyBuildPath, {base: config.build})
|
return gulp.src(pathConfig.uglifyBuildPath, {base: config.build})
|
||||||
|
.pipe(plumber({errorHandler: onErrorHandler}))
|
||||||
.pipe(uglify())
|
.pipe(uglify())
|
||||||
.pipe(gulp.dest(config.build))
|
.pipe(gulp.dest(config.build))
|
||||||
.on("end", reload);
|
.on("end", reload);
|
||||||
@@ -179,6 +196,7 @@ module.exports = function (pathConfig,config) {
|
|||||||
gulp.task('tmod_build', function () {
|
gulp.task('tmod_build', function () {
|
||||||
console.log(pathConfig.tmodBuildPath);
|
console.log(pathConfig.tmodBuildPath);
|
||||||
return gulp.src(pathConfig.tmodBuildPath)
|
return gulp.src(pathConfig.tmodBuildPath)
|
||||||
|
.pipe(plumber({errorHandler: onErrorHandler}))
|
||||||
.pipe(tmodjs({
|
.pipe(tmodjs({
|
||||||
templateBase: pathConfig.tmodBasePath,
|
templateBase: pathConfig.tmodBasePath,
|
||||||
output: pathConfig.tmodOutPath,
|
output: pathConfig.tmodOutPath,
|
||||||
|
|||||||
Reference in new issue
Block a user