diff --git a/.eslintrc.js b/.eslintrc.js
index c82d5d2cc..f63b6efd3 100644
--- a/.eslintrc.js
+++ b/.eslintrc.js
@@ -46,7 +46,6 @@ module.exports = {
'eol-last': 2,
'eqeqeq': [2, 'allow-null'],
'generator-star-spacing': [2, { 'before': true, 'after': true }],
- 'handle-callback-err': [2, '^(err|error)$' ],
'indent': [2, 2, { 'SwitchCase': 1 }],
'jsx-quotes': [2, 'prefer-double'],
'key-spacing': [2, { 'beforeColon': false, 'afterColon': true }],
diff --git a/.github/CONTRIBUTING.zh-CN.md b/.github/CONTRIBUTING.zh-CN.md
index b10f3e3a0..a01e1b8d5 100644
--- a/.github/CONTRIBUTING.zh-CN.md
+++ b/.github/CONTRIBUTING.zh-CN.md
@@ -62,7 +62,7 @@ vant
- 添加测试代码
-需要在 `test/unit/specs` 目录下增加对应组件的测试文件,以 .spec.js 结尾,如:`button.spec.js`。测试框架使用了 karma + mocha + sinon + chai,vue 相关的操作使用了 [avoriaz](https://github.com/eddyerburgh/avoriaz)
+需要在 `test/specs` 目录下增加对应组件的测试文件,以 .spec.js 结尾,如:`button.spec.js`。测试框架使用了 karma + mocha + sinon + chai,vue 相关的操作使用了 [avoriaz](https://github.com/eddyerburgh/avoriaz)
## 组件文档如何编写
diff --git a/.gitignore b/.gitignore
index 5f5aad3b6..64e81c8e1 100644
--- a/.gitignore
+++ b/.gitignore
@@ -5,13 +5,9 @@
.vscode
packages/**/lib
lib/
-lib/*
-!lib/index.js
-!lib/style.css
node_modules
example/dist
/docs/dist
-test/unit/coverage
+test/coverage
packages/vant-css/build
packages/vant-css/icons
-docs/examples-dist
diff --git a/.travis.yml b/.travis.yml
index 8d7976b81..4ef32670d 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -16,4 +16,4 @@ script:
npm run lint && npm run test
after_success:
- |
- cat ./test/unit/coverage/lcov.info | ./node_modules/.bin/codecov
+ cat ./test/coverage/lcov.info | ./node_modules/.bin/codecov
diff --git a/README.md b/README.md
index 9ea8ae4b4..1422e6426 100644
--- a/README.md
+++ b/README.md
@@ -62,7 +62,7 @@ import { Button } from 'vant';
#### 2. Manually import
```js
-import { Button } from 'vant/lib/button';
+import Button from 'vant/lib/button';
import 'vant/lib/vant-css/base.css';
import 'vant/lib/vant-css/button.css';
```
diff --git a/README.zh-CN.md b/README.zh-CN.md
index 90ab78423..76c8c13fa 100644
--- a/README.zh-CN.md
+++ b/README.zh-CN.md
@@ -59,7 +59,7 @@ import { Button } from 'vant';
#### 方式二. 按需引入组件
```js
-import { Button } from 'vant/lib/button';
+import Button from 'vant/lib/button';
import 'vant/lib/vant-css/base.css';
import 'vant/lib/vant-css/button.css';
```
diff --git a/build/bin/build-components.js b/build/bin/build-components.js
index 83040600b..04343f977 100644
--- a/build/bin/build-components.js
+++ b/build/bin/build-components.js
@@ -33,13 +33,11 @@ function compile(dir) {
// 移除 vant-css
if (file.indexOf('vant-css') !== -1) {
fs.removeSync(absolutePath);
- }
- // 遍历文件夹
- else if (isDir(absolutePath)) {
+ // 遍历文件夹
+ } else if (isDir(absolutePath)) {
return compile(absolutePath);
- }
- // 编译 .vue 文件
- else if (/\.vue$/.test(file)) {
+ // 编译 .vue 文件
+ } else if (/\.vue$/.test(file)) {
const source = fs.readFileSync(absolutePath, 'utf-8');
fs.removeSync(absolutePath);
@@ -49,9 +47,13 @@ function compile(dir) {
fs.outputFileSync(output, compiler(source, compilerOption).js);
} else if (/\.js$/.test(file)) {
- babel.transformFile(absolutePath, compilerOption.babel, (err, { code }) => {
- fs.outputFileSync(absolutePath, code);
- });
+ babel.transformFile(
+ absolutePath,
+ compilerOption.babel,
+ (err, { code }) => {
+ fs.outputFileSync(absolutePath, code);
+ }
+ );
}
});
}
diff --git a/build/bin/build-lib.js b/build/bin/build-lib.js
index 2afad14b0..1d1754b8a 100644
--- a/build/bin/build-lib.js
+++ b/build/bin/build-lib.js
@@ -13,8 +13,8 @@ const chalk = require('chalk');
require('shelljs/global');
// 1. lint
-log('Starting', 'lint');
-exec('npm run lint --silent');
+log('Starting', 'lint');
+exec('npm run lint --silent');
log('Finished', 'lint');
// 2. build entry
@@ -32,7 +32,7 @@ log('Starting', 'build:vant-css');
exec('npm run build:vant-css --silent');
log('Finished', 'build:vant-css');
-// 5. build vant.js
+// 5. build vant.js
log('Starting', 'build:vant');
exec('npm run build:vant --silent');
log('Finished', 'build:vant');
@@ -46,7 +46,7 @@ log('Finished', 'build:style-entries');
function log(status, action, breakLine) {
const now = new Date();
const clock = `${breakLine ? '\n' : ''}[${padZero(now.getHours())}:${padZero(now.getMinutes())}:${padZero(now.getSeconds())}]`;
- console.log(`${chalk.gray(clock)} ${status} '${action ? chalk.cyan.bold(action ) : ''}'`);
+ console.log(`${chalk.gray(clock)} ${status} '${action ? chalk.cyan.bold(action) : ''}'`);
}
function padZero(num) {
diff --git a/build/bin/build-style-entry.js b/build/bin/build-style-entry.js
index 4f062cc87..6d7779a2a 100644
--- a/build/bin/build-style-entry.js
+++ b/build/bin/build-style-entry.js
@@ -6,7 +6,6 @@ const fs = require('fs-extra');
const path = require('path');
const components = require('./get-components')();
const dependencyTree = require('dependency-tree');
-
const SEP = path.sep;
components.forEach(componentName => {
diff --git a/build/bin/get-components.js b/build/bin/get-components.js
index 08b3092d7..b6857cc53 100644
--- a/build/bin/get-components.js
+++ b/build/bin/get-components.js
@@ -4,5 +4,5 @@ const path = require('path');
module.exports = function() {
const dirs = fs.readdirSync(path.resolve(__dirname, '../../packages'));
const excludes = ['index.js', 'vant-css', 'mixins', 'utils', '.DS_Store'];
- return dirs.filter(dirName => excludes.indexOf(dirName) === -1)
-}
+ return dirs.filter(dirName => excludes.indexOf(dirName) === -1);
+};
diff --git a/build/webpack.build.js b/build/webpack.build.js
index 713359568..1a8a423bc 100644
--- a/build/webpack.build.js
+++ b/build/webpack.build.js
@@ -1,50 +1,29 @@
const webpack = require('webpack');
const config = require('./webpack.config.dev.js');
-const isMinify = process.argv.indexOf('-p') !== -1;
-const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
+const isMinify = process.argv.indexOf('-p') !== -1;
-config.entry = {
- 'vant': './packages/index.js'
-};
-
-config.output = {
- filename: isMinify ? './lib/[name].min.js' : './lib/[name].js',
- library: 'vant',
- libraryTarget: 'umd',
- umdNamedDefine: true
-};
-
-config.externals = {
- vue: {
- root: 'Vue',
- commonjs: 'vue',
- commonjs2: 'vue',
- amd: 'vue'
- }
-};
-
-config.plugins = [
- new webpack.DefinePlugin({
- 'process.env.NODE_ENV': '"production"'
- }),
- new webpack.LoaderOptionsPlugin({
- minimize: true,
- debug: false,
- options: {
- vue: {
- autoprefixer: false,
- preserveWhitespace: false
- }
+module.exports = Object.assign({}, config, {
+ entry: {
+ 'vant': './packages/index.js'
+ },
+ output: {
+ filename: isMinify ? './lib/[name].min.js' : './lib/[name].js',
+ library: 'vant',
+ libraryTarget: 'umd',
+ umdNamedDefine: true
+ },
+ externals: {
+ vue: {
+ root: 'Vue',
+ commonjs: 'vue',
+ commonjs2: 'vue',
+ amd: 'vue'
}
- }),
- new webpack.optimize.ModuleConcatenationPlugin()
-];
-
-// analyze bundle size if need
-// if (isMinify) {
-// config.plugins.push(new BundleAnalyzerPlugin());
-// }
-
-delete config.devtool;
-
-module.exports = config;
+ },
+ plugins: [
+ new webpack.DefinePlugin({
+ 'process.env.NODE_ENV': '"production"'
+ }),
+ new webpack.optimize.ModuleConcatenationPlugin()
+ ]
+});
diff --git a/build/webpack.config.dev.js b/build/webpack.config.dev.js
index 3acf74802..a98513df1 100644
--- a/build/webpack.config.dev.js
+++ b/build/webpack.config.dev.js
@@ -14,9 +14,8 @@ const cache = {
module.exports = {
entry: {
- vendor: ['packages'],
'vant-docs': './docs/src/index.js',
- 'vant-examples': './docs/src/examples.js'
+ 'vant-mobile': './docs/src/mobile.js'
},
output: {
path: path.join(__dirname, '../docs/dist'),
@@ -90,7 +89,6 @@ module.exports = {
}
]
},
- devtool: 'source-map',
plugins: [
new ProgressBarPlugin(),
new HtmlWebpackPlugin({
@@ -100,7 +98,7 @@ module.exports = {
inject: true
}),
new HtmlWebpackPlugin({
- chunks: ['vendor', 'vant-examples'],
+ chunks: ['vendor', 'vant-mobile'],
template: 'docs/src/index.tpl',
filename: 'examples.html',
inject: true
diff --git a/build/webpack.config.prod.js b/build/webpack.config.prod.js
index 972b0205f..6e4fe27b5 100644
--- a/build/webpack.config.prod.js
+++ b/build/webpack.config.prod.js
@@ -6,27 +6,17 @@ const devConfig = require('./webpack.config.dev.js');
module.exports = merge(devConfig, {
output: {
path: path.join(__dirname, '../docs/dist'),
- publicPath: 'https://b.yzcdn.cn/zanui/vant/',
+ publicPath: 'https://img.yzcdn.cn/zanui/vant/',
filename: '[name].[hash:8].js',
umdNamedDefine: true,
chunkFilename: 'async_[name].[chunkhash:8].js'
},
- devtool: false,
plugins: [
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify(process.env.NODE_ENV)
}
}),
- new webpack.optimize.UglifyJsPlugin({
- compress: {
- warnings: false,
- drop_console: true
- },
- output: {
- comments: false
- },
- sourceMap: false
- })
+ new webpack.optimize.UglifyJsPlugin()
]
});
diff --git a/docs/demos/index.js b/docs/demos/index.js
index a3c210b92..8e85dba4b 100644
--- a/docs/demos/index.js
+++ b/docs/demos/index.js
@@ -26,6 +26,7 @@ export default {
'address-list': asyncWrapper(r => require.ensure([], () => r(componentWrapper(require('./views/address-list'), 'address-list')), 'address-list')),
'area': asyncWrapper(r => require.ensure([], () => r(componentWrapper(require('./views/area'), 'area')), 'area')),
'badge': asyncWrapper(r => require.ensure([], () => r(componentWrapper(require('./views/badge'), 'badge')), 'badge')),
+ 'built-in-style': asyncWrapper(r => require.ensure([], () => r(componentWrapper(require('./views/built-in-style'), 'built-in-style')), 'built-in-style')),
'button': asyncWrapper(r => require.ensure([], () => r(componentWrapper(require('./views/button'), 'button')), 'button')),
'card': asyncWrapper(r => require.ensure([], () => r(componentWrapper(require('./views/card'), 'card')), 'card')),
'cell-swipe': asyncWrapper(r => require.ensure([], () => r(componentWrapper(require('./views/cell-swipe'), 'cell-swipe')), 'cell-swipe')),
diff --git a/docs/demos/views/built-in-style.vue b/docs/demos/views/built-in-style.vue
new file mode 100644
index 000000000..1c1a6a670
--- /dev/null
+++ b/docs/demos/views/built-in-style.vue
@@ -0,0 +1,85 @@
+
+
diff --git a/docs/demos/views/sku.vue b/docs/demos/views/sku.vue
index b09bb9ae8..34436aa82 100644
--- a/docs/demos/views/sku.vue
+++ b/docs/demos/views/sku.vue
@@ -10,9 +10,10 @@
:hide-stock="$t('sku').sku.hide_stock"
:quota="$t('sku').quota"
:quota-used="$t('sku').quota_used"
- :reset-stepper-on-hide="true"
- :reset-selected-sku-on-hide="true"
- :disable-stepper-input="true"
+ reset-stepper-on-hide
+ reset-selected-sku-on-hide
+ disable-stepper-input
+ :close-on-click-overlay="closeOnClickOverlay"
:message-config="messageConfig"
@buy-clicked="onBuyClicked"
@add-cart="onAddCartClicked"
@@ -48,10 +49,10 @@
:goods="$t('sku').goods_info"
:goods-id="$t('sku').goods_id"
:hide-stock="$t('sku').sku.hide_stock"
- :show-add-cart-btn="true"
:quota="$t('sku').quota"
:quota-used="$t('sku').quota_used"
- :reset-stepper-on-hide="true"
+ show-add-cart-btn
+ reset-stepper-on-hide
:initial-sku="initialSku"
@buy-clicked="onBuyClicked"
@add-cart="onAddCartClicked"
@@ -96,6 +97,7 @@ export default {
showBase: false,
showCustom: false,
showStepper: false,
+ closeOnClickOverlay: true,
initialSku: {
s1: '30349',
s2: '1193'
diff --git a/docs/demos/views/swipe.vue b/docs/demos/views/swipe.vue
index ca66d62d9..9b5e43ea8 100644
--- a/docs/demos/views/swipe.vue
+++ b/docs/demos/views/swipe.vue
@@ -16,6 +16,15 @@