update worker

This commit is contained in:
dengtongyu committed 2018-05-26 18:04:28 +08:00
1 parent b3b4e9e43f
commit d1781f8b1d
5 files changed
+1853 -1040

No files matched your search

+1828 -1002
View File
File diff suppressed because it is too large. Load diff
+4 -2
View File
@@ -22,16 +22,18 @@
"gulp-plumber": "^1.2.0", "gulp-plumber": "^1.2.0",
"gulp-stylus": "^2.7.0", "gulp-stylus": "^2.7.0",
"gulp-swig": "^0.8.0", "gulp-swig": "^0.8.0",
"gulp-tmod": "^2.0.3",
"gulp-uglify": "^3.0.0", "gulp-uglify": "^3.0.0",
"http-proxy-middleware": "^0.17.4", "http-proxy-middleware": "^0.17.4",
"run-sequence": "^2.2.1", "run-sequence": "^2.2.1",
"webpack-stream": "^4.0.3" "webpack-stream": "^4.0.3"
}, },
"dependencies": { "dependencies": {
"art-template-loader": "^1.4.3",
"browser-demote": "^1.0.6",
"chalk": "^2.4.1", "chalk": "^2.4.1",
"commander": "^2.15.1", "commander": "^2.15.1",
"gulp-contrib-copy": "^0.1.3", "gulp-contrib-copy": "^0.1.3",
"inquirer": "^5.2.0" "inquirer": "^5.2.0",
"webpack": "^4.9.1"
} }
} }
+16 -25
View File
@@ -10,7 +10,6 @@ const stylus = require('gulp-stylus');
const swig = require('gulp-swig'); const swig = require('gulp-swig');
const htmlmin = require('gulp-htmlmin'); const htmlmin = require('gulp-htmlmin');
const uglify = require('gulp-uglify'); const uglify = require('gulp-uglify');
const tmodjs = require('gulp-tmod');
const browserSync = require('browser-sync'); const browserSync = require('browser-sync');
const reload = browserSync.reload; const reload = browserSync.reload;
const proxyMiddleware = require('http-proxy-middleware'); const proxyMiddleware = require('http-proxy-middleware');
@@ -87,11 +86,22 @@ init = (pathName) => {
.pipe(webpack({ .pipe(webpack({
output: { output: {
filename: 'index.js', filename: 'index.js',
},
module: {
rules: [{
test: /\.art$/,
use: [{
loader: 'art-template-loader'
}]
}]
} }
})) }))
.pipe(babel({ .pipe(babel({
presets: ['env'] presets: ['env']
})) }))
.pipe(uglify({
ie8: true
}))
//.pipe(webpack( require('./webpack.config.js')(pathConfig.scriptBuildPath) )) //.pipe(webpack( require('./webpack.config.js')(pathConfig.scriptBuildPath) ))
.pipe(gulp.dest(pathConfig.babelOutPath)) .pipe(gulp.dest(pathConfig.babelOutPath))
.on("end", reload); .on("end", reload);
@@ -105,29 +115,10 @@ init = (pathName) => {
.pipe(plumber({ .pipe(plumber({
errorHandler: onErrorHandler errorHandler: onErrorHandler
})) }))
.pipe(uglify({
ie8: true
}))
.pipe(gulp.dest(config.build)) .pipe(gulp.dest(config.build))
.on("end", reload); .on("end", reload);
}); });
//tmod任务
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,
combo: false,
type: 'cmd'
}))
.on("end", reload);
});
//watch html任务 //watch html任务
gulp.task('html_build', function() { gulp.task('html_build', function() {
runSequence('swig_build', 'htmlmin_build'); runSequence('swig_build', 'htmlmin_build');
@@ -136,12 +127,12 @@ init = (pathName) => {
//watch js任务 //watch js任务
gulp.task('js_build', function() { gulp.task('js_build', function() {
//console.log('执行了js_build') //console.log('执行了js_build')
runSequence('babel_build', 'uglify_build'); runSequence('babel_build');
}); });
//watch tmodjs任务 //watch tmodjs任务
gulp.task('tmodjs_build', function() { gulp.task('art_build', function() {
runSequence('tmod_build', 'babel_build', 'uglify_build'); runSequence('babel_build');
}); });
//server任务 //server任务
@@ -177,13 +168,13 @@ init = (pathName) => {
gulp.task('build', function() { gulp.task('build', function() {
runSequence('stylus_build', 'swig_build', 'htmlmin_build', 'tmod_build', 'babel_build', 'uglify_build', function() { runSequence('stylus_build', 'swig_build', 'htmlmin_build', 'babel_build', function() {
console.log(chalk.green.bold(pathName + ' 打包完成!')); console.log(chalk.green.bold(pathName + ' 打包完成!'));
}); });
}); });
gulp.task('dev', function() { gulp.task('dev', function() {
runSequence('stylus_build', 'swig_build', 'htmlmin_build', 'tmod_build', 'babel_build', 'uglify_build', 'server'); runSequence('stylus_build', 'swig_build', 'htmlmin_build', 'babel_build', 'server');
}); });
} }
+1 -3
View File
@@ -37,9 +37,7 @@ exports.initPath = (pathName) => {
_pathConfig.uglifyBuildPath = _config.build + '/pages/' + pathName + '/index.js'; _pathConfig.uglifyBuildPath = _config.build + '/pages/' + pathName + '/index.js';
//tmod build目录 //tmod build目录
_pathConfig.tmodBuildPath = _config.base + '/pages/' + pathName + '/**/*.tmod'; _pathConfig.artBuildPath = _config.base + '/pages/' + pathName + '/**/*.art';
_pathConfig.tmodBasePath = _config.base + '/pages/';
_pathConfig.tmodOutPath = _config.base + '/script/tmodjs/';
return _pathConfig; return _pathConfig;
} }
+4 -8
View File
@@ -29,17 +29,13 @@ exports.init = (pathConfig,gulp) => {
taskName: ['js_build'], taskName: ['js_build'],
taskPath: 'scriptChangePath' taskPath: 'scriptChangePath'
}, { }, {
watchPath: pathConfig.uglifyBuildPath, watchPath: pathConfig.artBuildPath,
taskName: ['uglify_build'], taskName: ['art_build'],
taskPath: 'uglifyChangePath' taskPath: 'artChangePath'
}, {
watchPath: pathConfig.tmodBuildPath,
taskName: ['tmodjs_build'],
taskPath: 'tmodChangePath'
}]; }];
for (var i = 0; i < watchList.length; i++) { for (var i = 0; i < watchList.length; i++) {
if (watchList[i].taskName[0] == 'uglify_build' || watchList[i].taskName[0] == 'htmlmin_build') continue; //if (watchList[i].taskName[0] == 'uglify_build' || watchList[i].taskName[0] == 'htmlmin_build') continue;
gulp.watch(watchList[i].watchPath, watchList[i].taskName).on('change', function(event) { gulp.watch(watchList[i].watchPath, watchList[i].taskName).on('change', function(event) {
//let fileType = util.pathType(event.path); //let fileType = util.pathType(event.path);