...
|
...
|
@@ -4,11 +4,29 @@ |
|
|
* date; 2015/3/27
|
|
|
*/
|
|
|
var gulp = require('gulp'),
|
|
|
fs = require('fs'),
|
|
|
ftp = require('gulp-ftp'),
|
|
|
gutil = require('gulp-util'),
|
|
|
concat = require('gulp-concat'),
|
|
|
compass = require('gulp-compass'),
|
|
|
exec = require('child_process').exec,
|
|
|
server = require('gulp-develop-server');
|
|
|
|
|
|
var config = JSON.parse(fs.readFileSync('./package.json').toString());
|
|
|
var assets_dir = 'dist/' + config.name + '/assets';
|
|
|
var dist_dir = {
|
|
|
js: 'dist/' + config.name + '/' + config.version,
|
|
|
css: 'dist/' + config.name + '/' + config.version,
|
|
|
image: assets_dir + '/iamges',
|
|
|
font: assets_dir + '/fonts'
|
|
|
};
|
|
|
|
|
|
var ftpConfig = {
|
|
|
host: '58.213.133.26',
|
|
|
user: 'php',
|
|
|
pass: 'yoho9646'
|
|
|
};
|
|
|
|
|
|
// 启动
|
|
|
gulp.task('default', ['server', 'server:restart', 'compass-watch', 'compass']);
|
|
|
|
...
|
...
|
@@ -28,16 +46,14 @@ gulp.task('server:restart', function() { |
|
|
|
|
|
//compass 解析压缩合并
|
|
|
gulp.task('compass-watch', function() {
|
|
|
gulp.watch('public/sass/*.scss', ['compass']);
|
|
|
gulp.watch('public/sass/**/*.scss', ['compass']);
|
|
|
});
|
|
|
|
|
|
gulp.task('compass', function() {
|
|
|
gulp.src('public/sass/*.scss')
|
|
|
gulp.src('public/sass/**/*.scss')
|
|
|
.pipe(
|
|
|
compass({
|
|
|
config_file: 'config.rb',
|
|
|
css: 'public/css',
|
|
|
sass: 'public/sass'
|
|
|
config_file: 'config.rb'
|
|
|
})
|
|
|
)
|
|
|
});
|
...
|
...
|
@@ -63,3 +79,51 @@ gulp.task('build-production', function() { |
|
|
.pipe(concat('all.js'))
|
|
|
.pipe(gulp.dest('public/dist'))
|
|
|
});
|
|
|
|
|
|
//线上环境使用
|
|
|
//发布到CND
|
|
|
gulp.task('dist', ['compass-production', 'assets', 'spm-build-production'], function() {
|
|
|
var ftpstream = ftp(ftpConfig);
|
|
|
return gulp.src('dist*//**')
|
|
|
.pipe(ftpstream)
|
|
|
.pipe(gutil.noop());
|
|
|
});
|
|
|
|
|
|
//compass整合所有css到index后发布到发布目录
|
|
|
gulp.task('compass-production', function() {
|
|
|
gulp.src('public/sass/index.scss')
|
|
|
.pipe(
|
|
|
compass({
|
|
|
css: dist_dir.css,
|
|
|
sass: 'public/sass',
|
|
|
image: dist_dir.image,
|
|
|
font: dist_dir.font,
|
|
|
http_path: '/',
|
|
|
style: 'compressed'
|
|
|
})
|
|
|
)
|
|
|
.on('error', function(error) {
|
|
|
console.log(error);
|
|
|
this.emit('end');
|
|
|
});
|
|
|
});
|
|
|
|
|
|
//拷贝fonts+images到发布目录
|
|
|
gulp.task('assets',function() {
|
|
|
gulp.src('public/img/**')
|
|
|
.pipe(gulp.dest(dist_dir.image));
|
|
|
gulp.src('public/fonts/*')
|
|
|
.pipe(gulp.dest(dist_dir.font));
|
|
|
});
|
|
|
|
|
|
//spm
|
|
|
gulp.task('spm-build-production', function() {
|
|
|
exec('spm build --include all', function() {
|
|
|
gulp.src(['public/lib/sea-pro.js', 'dist/yohobuy-mobile/1.0.0/index-debug.js'])
|
|
|
.pipe(concat('index-debug.js'))
|
|
|
.pipe(gulp.dest(dist_dir.js));
|
|
|
gulp.src(['public/lib/sea-pro.js', 'dist/yohobuy-mobile/1.0.0/index.js'])
|
|
|
.pipe(concat('index.js'))
|
|
|
.pipe(gulp.dest(dist_dir.js))
|
|
|
});
|
|
|
}); |
|
|
\ No newline at end of file |
...
|
...
|
|