|
@@ -10,13 +10,16 @@ var gulp = require('gulp'), |
|
@@ -10,13 +10,16 @@ var gulp = require('gulp'), |
10
|
concat = require('gulp-concat'),
|
10
|
concat = require('gulp-concat'),
|
11
|
compass = require('gulp-compass'),
|
11
|
compass = require('gulp-compass'),
|
12
|
exec = require('child_process').exec,
|
12
|
exec = require('child_process').exec,
|
|
|
13
|
+ uglify = require('gulp-uglify'),
|
|
|
14
|
+ Package = require('father').SpmPackage,
|
|
|
15
|
+ transport = require('gulp-spm'),
|
13
|
server = require('gulp-develop-server');
|
16
|
server = require('gulp-develop-server');
|
14
|
|
17
|
|
15
|
var config = JSON.parse(fs.readFileSync('./package.json').toString());
|
18
|
var config = JSON.parse(fs.readFileSync('./package.json').toString());
|
16
|
-var assets_dir = 'dist/' + config.name + '/assets';
|
19
|
+var assets_dir = 'dist/yoho-mobile/' + config.name + '/assets';
|
17
|
var dist_dir = {
|
20
|
var dist_dir = {
|
18
|
- js: 'dist/' + config.name + '/' + config.version,
|
|
|
19
|
- css: 'dist/' + config.name + '/' + config.version,
|
21
|
+ js: 'dist/yoho-mobile/' + config.name + '/' + config.version,
|
|
|
22
|
+ css: 'dist/yoho-mobile/' + config.name + '/' + config.version,
|
20
|
image: assets_dir + '/images',
|
23
|
image: assets_dir + '/images',
|
21
|
font: assets_dir + '/fonts'
|
24
|
font: assets_dir + '/fonts'
|
22
|
};
|
25
|
};
|
|
@@ -97,11 +100,16 @@ gulp.task('compass-production', function() { |
|
@@ -97,11 +100,16 @@ gulp.task('compass-production', function() { |
97
|
});
|
100
|
});
|
98
|
});
|
101
|
});
|
99
|
|
102
|
|
100
|
-//spm build
|
103
|
+//STEP3: build
|
101
|
gulp.task('build', function() {
|
104
|
gulp.task('build', function() {
|
102
|
- exec('spm build', function() {
|
|
|
103
|
- //移动到发布目录
|
|
|
104
|
- fs.rename('dist/index-debug.js', dist_dir.js + '/index-debug.js');
|
|
|
105
|
- fs.rename('dist/index.js', dist_dir.js + '/index.js');
|
|
|
106
|
- });
|
105
|
+ var pkg = new Package(__dirname);
|
|
|
106
|
+ return gulp.src(pkg.main)
|
|
|
107
|
+ .pipe(transport({
|
|
|
108
|
+ pkg: pkg
|
|
|
109
|
+ }))
|
|
|
110
|
+ .pipe(concat('index-debug.js'))
|
|
|
111
|
+ .pipe(gulp.dest(distDir.js))
|
|
|
112
|
+ .pipe(uglify())
|
|
|
113
|
+ .pipe(concat('index.js'))
|
|
|
114
|
+ .pipe(gulp.dest(distDir.js));
|
107
|
}); |
115
|
}); |