...
|
...
|
@@ -9,6 +9,9 @@ var gulp=require('gulp'), |
|
|
autoprefixer = require('gulp-autoprefixer'),
|
|
|
server = require('gulp-develop-server'),
|
|
|
webpack = require('webpack');
|
|
|
var crypto = require('crypto');
|
|
|
var rename = require("gulp-rename");
|
|
|
var clean = require('gulp-clean');
|
|
|
|
|
|
|
|
|
var wconfig = require('./webpack.config');
|
...
|
...
|
@@ -29,6 +32,7 @@ var dist_dir = { |
|
|
};
|
|
|
|
|
|
var cdn_domain = 'http://cdn.yoho.cn/';
|
|
|
var md5="";
|
|
|
|
|
|
var ftpConfig = {
|
|
|
host: '218.94.75.58',
|
...
|
...
|
@@ -41,7 +45,7 @@ gulp.task('default',["sass","js"]); |
|
|
|
|
|
gulp.task('start',["default","default-watch","server"]);
|
|
|
|
|
|
gulp.task('build',["buildjs","assets","static-config"]);
|
|
|
gulp.task('build',["clean","buildjs","assets","static-config"]);//"static-config"
|
|
|
|
|
|
//预编译css
|
|
|
gulp.task('sass', function() {
|
...
|
...
|
@@ -64,13 +68,20 @@ gulp.task("default-watch",function(){ |
|
|
gulp.watch('sass/**/*.scss', ['sass']);
|
|
|
gulp.watch('js/**/*.js', ['js']);
|
|
|
});
|
|
|
|
|
|
gulp.task("clean",function(){
|
|
|
return gulp.src(dist_dir.js, {read: false})
|
|
|
.pipe(clean());
|
|
|
});
|
|
|
//发布js文件
|
|
|
gulp.task("buildjs",["js"],function(){
|
|
|
gulp.src(dist_dir.js + '/libs.js')
|
|
|
md5="-"+crypto.createHash('md5').update(new Date().toString()).digest('hex');
|
|
|
console.log(md5);
|
|
|
gulp.src(path.join(public_dir,"dist") + '/*.js')
|
|
|
.pipe(uglify())
|
|
|
.pipe(md5())
|
|
|
.pipe(gulp.dest('./dist/libs'));
|
|
|
.pipe(rename({
|
|
|
suffix:md5
|
|
|
}))
|
|
|
.pipe(gulp.dest(dist_dir.js));
|
|
|
});
|
|
|
//发布静态资源
|
|
|
gulp.task('assets', function() {
|
...
|
...
|
@@ -93,19 +104,15 @@ gulp.task("static-config",function(){ |
|
|
var files = fs.readdirSync('./dist/libs');
|
|
|
var staticConfig={
|
|
|
test:{
|
|
|
libs: '/dist/libs.js',
|
|
|
js: '/dist/index.js',
|
|
|
css:'/css/all.css'
|
|
|
path:'/dist'
|
|
|
},
|
|
|
preview: {
|
|
|
libs: cdn_domain + 'libs/' + files[0],
|
|
|
js: cdn_domain + config.name + '/' + config.version + '/index.js',
|
|
|
css: cdn_domain + config.name + '/' + config.version + '/all.css'
|
|
|
path: cdn_domain + config.name + '/' + config.version,
|
|
|
md5:md5
|
|
|
},
|
|
|
production: {
|
|
|
libs: cdn_domain + 'libs/' + files[0],
|
|
|
js: cdn_domain + config.name + '/' + config.version + '/index.js',
|
|
|
css: cdn_domain + config.name + '/' + config.version + '/all.css'
|
|
|
path: cdn_domain + config.name + '/' + config.version,
|
|
|
md5:md5
|
|
|
}
|
|
|
}
|
|
|
fs.writeFileSync('../server/staticConfig.js', "exports.staticDir = " + JSON.stringify(staticConfig));
|
...
|
...
|
|