49 lines
1.3 KiB
JavaScript
49 lines
1.3 KiB
JavaScript
/**
|
|
*
|
|
* @authors Tony.Deng (dengtongyu123@163.com)
|
|
* @date 2018-05-15 15:45:22
|
|
* @version $Id$
|
|
*/
|
|
|
|
const chalk = require('chalk');
|
|
//const util = require('./util');
|
|
|
|
|
|
exports.init = (pathConfig,gulp) => {
|
|
//let pathConfig = util.getPathConfig();
|
|
|
|
let watchList = [{
|
|
watchPath: pathConfig.styleBuildPath,
|
|
taskName: ['stylus_build'],
|
|
taskPath: 'styleChangePath'
|
|
}, {
|
|
watchPath: pathConfig.htmlBuildPath,
|
|
taskName: ['html_build'],
|
|
taskPath: 'swigChangePath'
|
|
}, {
|
|
watchPath: pathConfig.htmlminBuildPath,
|
|
taskName: ['htmlmin_build'],
|
|
taskPath: 'htmlminChangePath'
|
|
}, {
|
|
watchPath: pathConfig.scriptBuildPath,
|
|
taskName: ['js_build'],
|
|
taskPath: 'scriptChangePath'
|
|
}, {
|
|
watchPath: pathConfig.artBuildPath,
|
|
taskName: ['art_build'],
|
|
taskPath: 'artChangePath'
|
|
}];
|
|
|
|
for (var i = 0; i < watchList.length; i++) {
|
|
//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) {
|
|
//let fileType = util.pathType(event.path);
|
|
//pathConfig[watchList[fileType].taskPath] = path.relative(__dirname, event.path);
|
|
//added为新增,deleted为删除,changed为改变
|
|
//变化类型 和 变化的文件的路径
|
|
console.log(chalk.green(event.type + ' : ' + event.path));
|
|
|
|
});
|
|
}
|
|
} |