[improvement] 移除多余的日志信息 (#144)

* 正式编译移除 console 信息

* 移除无须的 warn
This commit is contained in:
Yao 2018-03-11 20:35:43 +08:00 committed by GitHub
parent 878c0ae70a
commit 3d016db8b0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 3495 additions and 28 deletions

View File

@ -32,7 +32,7 @@ module.exports = {
};
function resolveCancelClick({ componentId }) {
console.info('[zan:actionsheet:cancel]');
if (this.handleZanActionsheetCancel) {
this.handleZanActionsheetCancel({ componentId });
} else {

View File

@ -1,8 +1,14 @@
<template name="capsule">
<view class="zan-capsule zan-capsule--{{type}}">
<block wx:if="{{color}}">
<view class="zan-capsule__left" style="background: {{ color }}; border-color: {{ color }}">{{ leftText }}</view>
<view class="zan-capsule__right" style="color: {{ color }}; border-color: {{ color }}">{{ rightText }}</view>
<view
class="zan-capsule__left"
style="background: {{ color }}; border-color: {{ color }}"
>{{ leftText }}</view>
<view
class="zan-capsule__right"
style="color: {{ color }}; border-color: {{ color }}"
>{{ rightText }}</view>
</block>
<block wx:else>
<view class="zan-capsule__left">{{ leftText }}</view>

10
dist/field/index.js vendored
View File

@ -5,7 +5,7 @@ module.exports = {
const componentId = extractComponentId(event);
event.componentId = componentId;
console.info('[zan:field:change]', event);
if (this.handleZanFieldChange) {
return this.handleZanFieldChange(event);
@ -18,25 +18,21 @@ module.exports = {
const componentId = extractComponentId(event);
event.componentId = componentId;
console.info('[zan:field:focus]', event);
if (this.handleZanFieldFocus) {
return this.handleZanFieldFocus(event);
}
console.warn('页面缺少 handleZanFieldFocus 回调函数');
},
_handleZanFieldBlur(event) {
const componentId = extractComponentId(event);
event.componentId = componentId;
console.info('[zan:field:blur]', event);
if (this.handleZanFieldBlur) {
return this.handleZanFieldBlur(event);
}
console.warn('页面缺少 handleZanFieldBlur 回调函数');
}
};

View File

@ -9,7 +9,7 @@ function handle(e) {
function callback(componentId, value) {
const e = { componentId, value };
console.info('[zan:Select:change]', e);
if (this.handleZanSelectChange) {
this.handleZanSelectChange(e);

View File

@ -12,7 +12,7 @@ function handle(e, num) {
function callback(componentId, stepper) {
stepper = +stepper;
var e = { componentId, stepper };
console.info('[zan:stepper:change]', e);
if (this.handleZanStepperChange) {
this.handleZanStepperChange(e);

View File

@ -9,7 +9,7 @@ var Switch = {
if (loading || disabled) return;
console.info('[zan:switch:change]', { checked, componentId });
if (this.handleZanSwitchChange) {
this.handleZanSwitchChange({

2
dist/tab/index.js vendored
View File

@ -7,7 +7,7 @@ var Tab = {
const selectedId = dataset.itemId;
const data = { componentId, selectedId };
console.info('[zan:tab:change]', data);
if (this.handleZanTabChange) {
this.handleZanTabChange(data);
} else {

3453
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -8,7 +8,7 @@
},
"scripts": {
"release": "sh scripts/release.sh",
"components": "node scripts/build-components.js --color",
"components": "cross-env NODE_ENV=production node scripts/build-components.js --color",
"changelog": "sh scripts/build-changelog.sh",
"icon": "sh scripts/build-icon.sh",
"dev": "node scripts/build-dev.js --color",
@ -29,10 +29,12 @@
],
"homepage": "https://github.com/youzan/zanui-weapp#readme",
"devDependencies": {
"cross-env": "^5.1.4",
"fs-extra": "^4.0.2",
"gulp": "^3.9.1",
"gulp-clean-css": "^3.9.0",
"gulp-postcss": "^7.0.0",
"gulp-remove-logging": "^1.2.0",
"gulp-rename": "^1.2.2",
"gulp-util": "^3.0.8",
"node-watch": "^0.5.5",

View File

@ -1,8 +1,14 @@
<template name="capsule">
<view class="zan-capsule zan-capsule--{{type}}">
<block wx:if="{{color}}">
<view class="zan-capsule__left" style="background: {{ color }}; border-color: {{ color }}">{{ leftText }}</view>
<view class="zan-capsule__right" style="color: {{ color }}; border-color: {{ color }}">{{ rightText }}</view>
<view
class="zan-capsule__left"
style="background: {{ color }}; border-color: {{ color }}"
>{{ leftText }}</view>
<view
class="zan-capsule__right"
style="color: {{ color }}; border-color: {{ color }}"
>{{ rightText }}</view>
</block>
<block wx:else>
<view class="zan-capsule__left">{{ leftText }}</view>

View File

@ -23,8 +23,6 @@ module.exports = {
if (this.handleZanFieldFocus) {
return this.handleZanFieldFocus(event);
}
console.warn('页面缺少 handleZanFieldFocus 回调函数');
},
_handleZanFieldBlur(event) {
@ -36,7 +34,5 @@ module.exports = {
if (this.handleZanFieldBlur) {
return this.handleZanFieldBlur(event);
}
console.warn('页面缺少 handleZanFieldBlur 回调函数');
}
};

View File

@ -3,10 +3,12 @@ const postcss = require('gulp-postcss');
const cssmin = require('gulp-clean-css');
const rename = require('gulp-rename');
const gutil = require('gulp-util');
const removeLogging = require('gulp-remove-logging');
const options = gutil.env;
const isProduction = process.env.NODE_ENV === 'production';
gulp.task('compile', () => {
gulp.task('compile-css', () => {
return gulp.src(['../../packages/**/*.pcss', '!../../packages/**/_*.pcss'])
.pipe(postcss())
.pipe(cssmin())
@ -16,4 +18,12 @@ gulp.task('compile', () => {
.pipe(gulp.dest(options.dist));
});
gulp.task('build', ['compile']);
gulp.task('compile-js', () => {
return gulp.src(['../../packages/**/*.js'])
.pipe(removeLogging({
methods: isProduction ? ['log', 'info'] : []
}))
.pipe(gulp.dest(options.dist));
});
gulp.task('build', ['compile-css', 'compile-js']);

View File

@ -20,12 +20,10 @@ function extracter(config = {}) {
fs.copySync(config.src, config.dist, {
filter(src = '') {
const extname = path.extname(src);
return ['.pcss', '.md'].indexOf(extname) < 0;
return ['.js', '.pcss', '.md'].indexOf(extname) < 0;
}
});
// js 无需编译,让微信开发者工具处理
// 编译 wxss 文件
exec(`gulp build --gulpfile scripts/utils/build-css.js --dist ${config.dist} --color`);
// 编译 js wxss 文件
exec(`gulp build --gulpfile scripts/utils/build.js --dist ${config.dist} --color`);
}