Permalink
Browse files

1.3.1 预发布

1. 增加 sftp 上传
2. 增加 sass 支持
3. 去除 开发 阶段 rem 转换
  • Loading branch information...
littledu committed Jun 28, 2016
1 parent 238d662 commit d48331d3ce227e5dfe4482e5f9fdcc1c5533bfa6
Showing with 216 additions and 48 deletions.
  1. +13 −9 app.html
  2. +15 −6 assets/css/app.css
  3. +3 −1 package.json
  4. +39 −4 src/_tasks/dev.js
  5. +39 −10 src/_tasks/dist.js
  6. +5 −5 src/_tasks/ftp.js
  7. +69 −0 src/_tasks/sftp.js
  8. +31 −12 src/app.js
  9. BIN templates/example.zip
  10. +2 −1 weflow.config.json
View
@@ -107,12 +107,12 @@
<div class="bottom-fixed">
<div class="tasks" id="js-tasks">
<span data-task="dev" id="js-build-dev" class="tasks__button">开发</span>
<span data-task="dist" class="tasks__button">生产编译</span>
<span data-task="ftp" class="tasks__button">FTP 部署</span>
<span data-task="zip" class="tasks__button">Zip 打包</span>
<span data-task="dist" class="tasks__button">编译</span>
<span data-task="ftp" class="tasks__button">上传</span>
<span data-task="zip" class="tasks__button">打包</span>
</div>
<div class="logs" id="js-log">
<span class="icon icon-clean" id="js-clean-log"></span>
<span class="icon icon-clean" id="js-clean-log" title="清除日志"></span>
<div class="logs__inner">
</div>
@@ -171,16 +171,20 @@
</div>
<div class="setting__section">
<div class="setting__hd">FTP 配置</div>
<div class="setting__hd">设置</div>
<div class="setting__bd">
<label class="setting__subtitle">FTP配置</label>
<div class="ui-text">
<label class="setting__subtitle">上传配置(默认为 FTP)</label>
<div class="ui-text ui-text_short">
<input type="text" name="ftp-host" placeholder="服务器地址" value="">
</div>
<div class="ui-text">
<div class="ui-checkbox sftp">
<input type="checkbox" name="ftp-ssh" id="sftp">
<label for="sftp">使用 SFTP</label>
</div>
<div class="ui-text ui-text_short">
<input type="text" name="ftp-user" placeholder="用户名" value="">
</div>
<div class="ui-text">
<div class="ui-text ui-text_short">
<input type="password" name="ftp-pass" placeholder="密码" value="">
</div>
<div class="ui-text">
View
@@ -594,6 +594,7 @@ html, body {
}
.setting__bd {
position: relative;
padding: 0 15px;
}
@@ -613,6 +614,16 @@ input:focus {
padding: 0 1px;
}
.ui-text_short{
width: 179px;
}
.sftp{
position: absolute;
left: 211px;
top: 29px;
}
.ui-text input {
position: relative;
z-index: 1;
@@ -653,13 +664,15 @@ input:focus {
.ui-checkbox label {
position: relative;
margin-left: 7px;
-webkit-user-select: none;
}
.ui-checkbox input + label:before {
content: '';
position: absolute;
left: -27px;
top: 0;
left: -23px;
top: 1px;
width: 14px;
height: 14px;
background-image: url(../img/checkbox.png);
@@ -670,10 +683,6 @@ input:focus {
background-image: url(../img/checkbox-on.png);
}
.ui-checkbox input {
margin-right: 10px;
}
.setting__subtitle {
display: block;
font-size: 12px;
View
@@ -1,6 +1,6 @@
{
"name": "WeFlow",
"version": "1.2.1",
"version": "1.3.1",
"release": "1.2.1",
"description": "A minimal Electron application",
"main": "main.js",
@@ -62,6 +62,8 @@
"gulp-replace": "^0.5.4",
"gulp-rev-all": "^0.8.22",
"gulp-rev-delete-original": "^0.1.0",
"gulp-sass": "^2.3.2",
"gulp-sftp": "^0.1.5",
"gulp-tmtsprite": "^0.0.20",
"gulp-uglify": "^1.5.3",
"gulp-usemin2": "^0.2.4",
View
@@ -6,10 +6,10 @@ const ejshelper = require('tmt-ejs-helper');
const async = require('async');
const gulp = require('gulp');
const less = require('gulp-less');
const gulpif = require('gulp-if');
const lazyImageCSS = require('gulp-lazyimagecss'); // 自动为图片样式添加 宽/高/background-size 属性
const postcss = require('gulp-postcss'); // CSS 预处理
const posthtml = require('gulp-posthtml'); // HTML 预处理
const sass = require('gulp-sass');
const Common = require(path.join(__dirname, '../common.js'));
function dev(projectPath, log, callback) {
@@ -43,6 +43,8 @@ function dev(projectPath, log, callback) {
media: path.join(projectPath, './src/media/**/*'),
less: [path.join(projectPath, './src/css/style-*.less'), path.join(projectPath, './src/css/**/*.css')],
lessAll: path.join(projectPath, './src/css/**/*.less'),
sass: path.join(projectPath, './src/css/style-*.scss'),
sassAll: path.join(projectPath, './src/css/**/*.scss'),
html: [path.join(projectPath, './src/html/**/*.html'), path.join(projectPath, '!./src/html/_*/**/**.html')],
htmlAll: path.join(projectPath, './src/html/**/*.html')
},
@@ -76,7 +78,7 @@ function dev(projectPath, log, callback) {
function compileLess(cb) {
gulp.src(paths.src.less)
.pipe(less())
.pipe(less({relativeUrls: true}))
.on('error', function (error) {
console.log(error.message);
})
@@ -93,7 +95,30 @@ function dev(projectPath, log, callback) {
reloadHandler();
}
})
};
}
//编译 sass
function compileSass(cb) {
gulp.src(paths.src.sass)
.pipe(sass())
.on('error', function(error){
console.log(error.message);
log(error.message);
})
.pipe(lazyImageCSS({imagePath: lazyDir}))
.pipe(gulp.dest(paths.dev.css))
.on('data', function () {
})
.on('end', function () {
if (cb) {
console.log('compile Sass success.');
log('compile Sass success.');
cb();
} else {
reloadHandler();
}
})
}
//编译 html
function compileHtml(cb) {
@@ -124,6 +149,7 @@ function dev(projectPath, log, callback) {
paths.src.js,
paths.src.media,
paths.src.lessAll,
paths.src.sassAll,
paths.src.htmlAll
],
{ignored: /[\/\\]\./}
@@ -201,11 +227,17 @@ function dev(projectPath, log, callback) {
case 'css':
var ext = path.extname(file);
if (type === 'removed') {
var tmp = file.replace(/src/, 'dev').replace('.less', '.css');
del([tmp], {force: true});
} else {
compileLess();
if (ext === '.less') {
compileLess();
} else {
compileSass();
}
}
break;
@@ -290,6 +322,9 @@ function dev(projectPath, log, callback) {
function (cb) {
compileLess(cb);
},
function (cb) {
compileSass(cb);
},
function (cb) {
compileHtml(cb);
}
View
@@ -25,6 +25,7 @@ const posthtml = require('gulp-posthtml');
const posthtmlPx2rem = require('posthtml-px2rem');
const RevAll = require('gulp-rev-all'); // reversion
const revDel = require('gulp-rev-delete-original');
const sass = require('gulp-sass');
const Common = require(path.join(__dirname, '../common'));
let webp = require(path.join(__dirname, './common/webp'));
@@ -35,16 +36,16 @@ function dist(projectPath, log, callback) {
let projectConfigPath = path.join(projectPath, 'weflow.config.json');
let config = null;
if(Common.fileExist(projectConfigPath)){
if (Common.fileExist(projectConfigPath)) {
config = Common.requireUncached(projectConfigPath);
}else{
} else {
config = Common.requireUncached(path.join(__dirname, '../../weflow.config.json'));
}
let lazyDir = config.lazyDir || ['../slice'];
if(Common.PLATFORM === 'win32'){
for(let i = 0; i < lazyDir.length; i++){
if (Common.PLATFORM === 'win32') {
for (let i = 0; i < lazyDir.length; i++) {
lazyDir[i] = lazyDir[i].replace(/\//g, '\\');
}
}
@@ -74,7 +75,7 @@ function dist(projectPath, log, callback) {
js: path.join(projectPath, './src/js/**/*.js'),
media: path.join(projectPath, './src/media/**/*'),
less: path.join(projectPath, './src/css/style-*.less'),
lessAll: path.join(projectPath, './src/css/**/*.less'),
sass: path.join(projectPath, './src/css/style-*.scss'),
html: [path.join(projectPath, './src/html/**/*.html'), path.join(projectPath, '!./src/html/_*/**.html')],
htmlAll: path.join(projectPath, './src/html/**/*')
},
@@ -104,25 +105,50 @@ function dist(projectPath, log, callback) {
})
}
function condition(file){
function condition(file) {
return path.extname(file.path) === '.png';
}
//编译 less
function compileLess(cb) {
gulp.src(paths.src.less)
.pipe(less())
.pipe(less({relativeUrls: true}))
.on('error', function (error) {
console.log(error.message);
log(error.message);
})
.pipe(lazyImageCSS({imagePath: lazyDir}))
.pipe(tmtsprite({margin: 4}))
.pipe(gulpif(condition, gulp.dest(paths.tmp.sprite), gulp.dest(paths.tmp.css)))
.on('data', function(){})
.on('data', function () {
})
.on('end', function () {
console.log('compileLess success.');
log('compileLess success.');
cb && cb();
})
}
//编译 sass
function compileSass(cb) {
gulp.src(paths.src.sass)
.pipe(sass())
.on('error', function (error) {
console.log(error.message);
log(error.message);
})
.pipe(lazyImageCSS({imagePath: lazyDir}))
.pipe(tmtsprite({margin: 4}))
.pipe(gulpif(condition, gulp.dest(paths.tmp.sprite), gulp.dest(paths.tmp.css)))
.on('data', function () {
})
.on('end', function () {
console.log('compileSass success.');
log('compileSass success.');
cb && cb();
})
}
//自动补全
function compileAutoprefixer(cb) {
gulp.src(paths.tmp.cssAll)
@@ -334,12 +360,15 @@ function dist(projectPath, log, callback) {
* 先删除目标目录,保证最新
* @param next
*/
function (next) {
function (next) {
delDist(next);
},
function (next) {
compileLess(next);
},
function (next) {
compileSass(next);
},
function (next) {
compileAutoprefixer(next);
},
@@ -374,7 +403,7 @@ function dist(projectPath, log, callback) {
function (next) {
reversion(next);
},
function(next){
function (next) {
supportWebp(next);
},
function (next) {
View
@@ -10,19 +10,19 @@ const util = require('./lib/util');
const Common = require(path.join(__dirname, '../common'));
module.exports = function (projectPath, log, callback) {
let projectConfigPath = path.join(projectPath, 'weflow.config.json');
let config = null;
if(Common.fileExist(projectConfigPath)){
if (Common.fileExist(projectConfigPath)) {
config = Common.requireUncached(projectConfigPath);
}else{
} else {
config = Common.requireUncached(path.join(__dirname, '../../weflow.config.json'));
}
let configFTP = config.ftp;
if(configFTP.host === '' || configFTP.port === '' || configFTP.user === ''){
if (configFTP.host === '' || configFTP.port === '' || configFTP.user === '') {
callback('ftp config');
return;
}
@@ -56,7 +56,7 @@ module.exports = function (projectPath, log, callback) {
async.series([
function (next) {
remoteFtp(next);
},
}
], function (err) {
if (err) {
throw new Error(err);
Oops, something went wrong.

0 comments on commit d48331d

Please sign in to comment.