Skip to content

Commit 0a0d721

Browse files
李钿李钿
authored andcommitted
增加 gulpfile 实现测试服务器自动编译部署
1 parent bc61b6a commit 0a0d721

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

gulpfile.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
var gulp = require('gulp');
2+
var webpack = require('webpack');
3+
var clean = require('gulp-clean');
4+
var gutil = require('gulp-util');
5+
var ftp = require( 'vinyl-ftp' );
6+
var deploy = require('./deploy.config.json');
7+
var deploy_remote_path = "/public/17zt/viewer"
8+
var webpack_config_demo = require('./webpack.config.example.js');
9+
// var webpack_config_dist = require('./webpack.config.dist.js');
10+
11+
gulp.task("clean:demo", function(){
12+
return gulp.src('./demo', {read: false})
13+
.pipe(clean());
14+
})
15+
16+
gulp.task('build:demo', ['clean:demo'], function(callback) {
17+
webpack(webpack_config_demo, function (error,status) {
18+
//gulp 异步任务必须明确执行 callback() 否则 gulp 将一直卡住
19+
callback()
20+
});
21+
});
22+
23+
gulp.task('deploy:demo', ['build:demo'], function () {
24+
deploy.log = gutil.log;
25+
26+
var conn = ftp.create(deploy);
27+
28+
return gulp.src('demo/**')
29+
.pipe(conn.dest(deploy_remote_path))
30+
})
31+
32+
gulp.task('demo', ['deploy:demo']);

package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"description": "Images viewer is a react component use in mobile website App, that function same as Weixin native viewer.",
55
"main": "index.js",
66
"scripts": {
7-
"start": "webpack-dev-server --config webpack.config.js",
7+
"start": "webpack-dev-server --config webpack.config.js",
88
"example": "rm -rf ./demo/* & NODE_ENV=development webpack --config webpack.config.example.js",
99
"test": "echo \"Error: no test specified\" && exit 1"
1010
},
@@ -33,12 +33,16 @@
3333
"babel-preset-stage-1": "^6.24.1",
3434
"css-loader": "^0.28.4",
3535
"file-loader": "^0.11.1",
36+
"gulp": "^3.9.1",
37+
"gulp-clean": "^0.3.2",
38+
"gulp-util": "^3.0.8",
3639
"html-webpack-plugin": "^2.28.0",
3740
"less": "^2.7.2",
3841
"less-loader": "^4.0.4",
3942
"postcss-loader": "^2.0.5",
4043
"style-loader": "^0.18.1",
4144
"url-loader": "^0.5.8",
45+
"vinyl-ftp": "^0.6.0",
4246
"webpack": "^2.6.1",
4347
"webpack-dev-server": "^2.4.5"
4448
},

0 commit comments

Comments
 (0)