diff --git a/.babelrc b/.babelrc
index c72eeb3a2..e3a543196 100644
--- a/.babelrc
+++ b/.babelrc
@@ -1,12 +1,9 @@
{
- "presets": [
- [
- "es2015",
- { "modules": false }
- ]
- ],
- "plugins": [
- "transform-runtime",
- "transform-vue-jsx"
- ]
-}
\ No newline at end of file
+ "presets": [["env", { "modules": false, "loose": true }]],
+ "plugins": ["transform-vue-jsx", "transform-runtime", "transform-object-rest-spread"],
+ "env": {
+ "commonjs": {
+ "presets": [["env", { "modules": "commonjs", "loose": true }]]
+ }
+ }
+}
diff --git a/CHANGELOG.md b/CHANGELOG.md
deleted file mode 100644
index e69de29bb..000000000
diff --git a/build/bin/build-all.js b/build/bin/build-all.js
deleted file mode 100644
index 565edeee2..000000000
--- a/build/bin/build-all.js
+++ /dev/null
@@ -1,25 +0,0 @@
-'use strict';
-
-const components = require('../../components.json');
-const execSync = require('child_process').execSync;
-const existsSync = require('fs').existsSync;
-const path = require('path');
-
-const componentPaths = [];
-
-delete components.font;
-
-Object.keys(components).forEach(key => {
- const filePath = path.join(__dirname, `../../packages/${key}/webpack.conf.js`);
-
- if (existsSync(filePath)) {
- componentPaths.push(`packages/${key}/webpack.conf.js`);
- }
-});
-
-const paths = componentPaths.join(',');
-const cli = `node_modules/.bin/webpack build -c ${paths} -p`;
-
-execSync(cli, {
- stdio: 'inherit'
-});
diff --git a/build/bin/build-components.js b/build/bin/build-components.js
new file mode 100644
index 000000000..84a81f81c
--- /dev/null
+++ b/build/bin/build-components.js
@@ -0,0 +1,52 @@
+/**
+ * 编译 components 到 lib 目录
+ */
+const fs = require('fs-extra');
+const path = require('path');
+const compiler = require('vue-sfc-compiler');
+const libDir = path.resolve(__dirname, '../../lib');
+const srcDir = path.resolve(__dirname, '../../packages');
+require('shelljs/global');
+
+// 清空 lib 目录
+fs.emptyDirSync(libDir);
+
+// 复制 packages
+fs.copySync(srcDir, libDir);
+
+// 编译所有 .vue 文件到 .js
+compileVueFiles(libDir);
+
+// babel 编译
+exec('cross-env BABEL_ENV=commonjs babel lib --out-dir lib');
+
+function compileVueFiles(dir) {
+ const files = fs.readdirSync(dir);
+
+ files.forEach(file => {
+ const absolutePath = path.resolve(dir, file);
+
+ // 移除 vant-css
+ if (file.indexOf('vant-css') !== -1) {
+ fs.removeSync(absolutePath);
+ }
+ // 遍历文件夹
+ else if (isDir(absolutePath)) {
+ return compileVueFiles(absolutePath);
+ }
+ // 编译 .vue 文件
+ else if (/\.vue$/.test(file)) {
+ const source = fs.readFileSync(absolutePath, 'utf-8');
+ fs.removeSync(absolutePath);
+
+ const outputVuePath = absolutePath + '.js';
+ const outputJsPath = absolutePath.replace('.vue', '.js');
+ const output = fs.existsSync(outputJsPath) ? outputVuePath : outputJsPath;
+ fs.outputFileSync(output, compiler(source));
+ }
+ });
+}
+
+function isDir(dir) {
+ return fs.lstatSync(dir).isDirectory();
+}
diff --git a/build/bin/build-entry.js b/build/bin/build-entry.js
index db939e763..6294590f1 100644
--- a/build/bin/build-entry.js
+++ b/build/bin/build-entry.js
@@ -4,8 +4,8 @@ var render = require('json-templater/string');
var uppercamelcase = require('uppercamelcase');
var path = require('path');
-var OUTPUT_PATH = path.join(__dirname, '../../src/index.js');
-var IMPORT_TEMPLATE = 'import {{name}} from \'../packages/{{package}}/index.js\';';
+var OUTPUT_PATH = path.join(__dirname, '../../packages/index.js');
+var IMPORT_TEMPLATE = 'import {{name}} from \'./{{package}}\';';
var ISNTALL_COMPONENT_TEMPLATE = ' {{name}}';
var MAIN_TEMPLATE = `{{include}}
diff --git a/build/bin/build-lib.js b/build/bin/build-lib.js
index 08155459a..0f59e218f 100644
--- a/build/bin/build-lib.js
+++ b/build/bin/build-lib.js
@@ -3,11 +3,11 @@
* Steps:
* 1. 清理目录
* 2. 构建 JS 入口文件
- * 3. 打包 JS 文件:vant.js && vant.min.js
- * 4. 构建 CSS 文件:vant-css
- * 5. 构建每个组件对应的 [component].js
+ * 3. 代码格式校验
+ * 4. 构建每个组件对应的 [component].js
+ * 5. 构建 vant-css
* 6. 生成每个组件目录下的 style 入口
- * 7. 编译 utils
+ * 7. 打包 JS 文件:vant.js && vant.min.js
*/
const fs = require('fs');
@@ -16,37 +16,27 @@ const components = require('../../components.json');
const chalk = require('chalk');
require('shelljs/global');
-// clean dir
-log('Starting', 'clean');
-exec('npm run clean --silent');
-log('Finished', 'clean');
-
-// build entry
-log('Starting', 'build:entry');
-exec('npm run build:file --silent');
-log('Finished', 'build:entry');
-
-// lint
+// 1. lint
log('Starting', 'lint');
exec('npm run lint --silent');
log('Finished', 'lint');
-// build vant.js
-log('Starting', 'build:vant');
-exec('npm run build:vant --silent');
-log('Finished', 'build:vant');
+// 2. build entry
+log('Starting', 'build:entry');
+exec('npm run build:file --silent');
+log('Finished', 'build:entry');
-// build [component].js
+// 3. build [component].js
log('Starting', 'build:component');
exec('npm run build:components --silent');
log('Finished', 'build:component');
-// build vant-css
+// 4. build vant-css
log('Starting', 'build:vant-css');
exec('npm run build:vant-css --silent');
log('Finished', 'build:vant-css');
-// build style entrys
+// 5. build style entrys
log('Starting', 'build:style-entries');
Object.keys(components).forEach((componentName) => {
const dir = path.join(__dirname, '../../lib/', componentName, '/style');
@@ -61,10 +51,10 @@ Object.keys(components).forEach((componentName) => {
});
log('Finished', 'build:style-entries');
-// build utils
-log('Starting', 'build:utils');
-exec('npm run build:utils --silent');
-log('Finished', 'build:utils');
+// 6. build vant.js
+log('Starting', 'build:vant');
+exec('npm run build:vant --silent');
+log('Finished', 'build:vant');
// helpers
function log(status, action, breakLine) {
diff --git a/build/webpack.build.js b/build/webpack.build.js
index 0ce2bb610..2b53cbae7 100644
--- a/build/webpack.build.js
+++ b/build/webpack.build.js
@@ -3,7 +3,7 @@ const config = require('./webpack.config.dev.js');
const isMinify = process.argv.indexOf('-p') !== -1;
config.entry = {
- 'vant': './src/index.js'
+ 'vant': './packages/index.js'
};
config.output = {
diff --git a/build/webpack.components.js b/build/webpack.components.js
deleted file mode 100644
index d5a3c18fb..000000000
--- a/build/webpack.components.js
+++ /dev/null
@@ -1,31 +0,0 @@
-const path = require('path');
-const Components = require('../components.json');
-const config = require('./webpack.build.js');
-const webpack = require('webpack');
-
-delete config.devtool;
-
-const entry = {};
-Object.keys(Components).forEach(key => {
- entry[key + '/index'] = Components[key];
-});
-
-config.entry = entry;
-
-config.externals = {
- vue: {
- root: 'Vue',
- commonjs: 'vue',
- commonjs2: 'vue',
- amd: 'vue'
- }
-};
-
-config.output = {
- path: path.join(__dirname, '../lib'),
- filename: '[name].js',
- libraryExport: "default",
- libraryTarget: 'umd'
-};
-
-module.exports = config;
diff --git a/build/webpack.config.dev.js b/build/webpack.config.dev.js
index 89ae7be1f..737712be8 100644
--- a/build/webpack.config.dev.js
+++ b/build/webpack.config.dev.js
@@ -38,7 +38,6 @@ module.exports = {
extensions: ['.js', '.vue', '.css'],
alias: {
vue: 'vue/dist/vue.runtime.esm.js',
- src: path.join(__dirname, '../src'),
packages: path.join(__dirname, '../packages'),
lib: path.join(__dirname, '../lib'),
components: path.join(__dirname, '../docs/src/components')
@@ -68,7 +67,7 @@ module.exports = {
},
{
test: /\.js$/,
- exclude: /node_modules|vue-router\/|vue-loader\/|vue-hot-reload-api\//,
+ exclude: /node_modules|vue-router\/|vue-loader\//,
loader: 'babel-loader'
},
{
diff --git a/docs/examples-docs/actionsheet.md b/docs/examples-docs/actionsheet.md
index bb7a56f26..a3e353a49 100644
--- a/docs/examples-docs/actionsheet.md
+++ b/docs/examples-docs/actionsheet.md
@@ -53,7 +53,7 @@ export default {
}
-## ActionSheet 行动按钮
+## Actionsheet 行动按钮
### 代码演示
@@ -106,11 +106,11 @@ export default {
```
:::
-#### 带取消按钮的ActionSheet
+#### 带取消按钮的 Actionsheet
-如果传入了`cancelText`属性,且不为空,则会在下方显示一个取消按钮,点击会将当前`ActionSheet`关闭。
+如果传入了`cancelText`属性,且不为空,则会在下方显示一个取消按钮,点击会将当前`Actionsheet`关闭。
-:::demo 带取消按钮的ActionSheet
+:::demo 带取消按钮的 Actionsheet
```html
弹出带取消按钮的actionsheet
@@ -149,11 +149,11 @@ export default {
```
:::
-#### 带标题的ActionSheet
+#### 带标题的 Actionsheet
-如果传入了`title`属性,且不为空,则另外一种样式的`ActionSheet`,里面内容需要自定义。
+如果传入了`title`属性,且不为空,则另外一种样式的`Actionsheet`,里面内容需要自定义。
-:::demo 带标题的ActionSheet
+:::demo 带标题的 Actionsheet
```html
弹出带标题的actionsheet
@@ -170,10 +170,11 @@ export default {
| title | 标题 | `String` | | |
| cancelText | 取消按钮文案 | `String` | | |
| overlay | 是否显示遮罩 | `Boolean` | | |
-| closeOnClickOverlay | 点击遮罩是否关闭`ActionSheet` | `Boolean` | | |
+| closeOnClickOverlay | 点击遮罩是否关闭`Actionsheet` | `Boolean` | | |
### actions
+
`API`中的`actions`为一个对象数组,数组中的每一个对象配置每一列,每一列有以下`key`:
| key | 说明 |
diff --git a/docs/examples-docs/changelog.md b/docs/examples-docs/changelog.md
index 3255b8fc7..e168e0f9a 100644
--- a/docs/examples-docs/changelog.md
+++ b/docs/examples-docs/changelog.md
@@ -90,7 +90,7 @@
**非兼容更新和新特性:**
-- src/utils目录支持SSR [\#51](https://github.com/youzan/vant/pull/51) ([cookfront](https://github.com/cookfront))
+- packages/utils目录支持SSR [\#51](https://github.com/youzan/vant/pull/51) ([cookfront](https://github.com/cookfront))
## [v0.6.3](https://github.com/youzan/vant/tree/v0.6.3) (2017-07-04)
[Full Changelog](https://github.com/youzan/vant/compare/v0.6.2...v0.6.3)
diff --git a/docs/examples-docs/dialog.md b/docs/examples-docs/dialog.md
index 8fbcca762..a40704c8c 100644
--- a/docs/examples-docs/dialog.md
+++ b/docs/examples-docs/dialog.md
@@ -7,7 +7,7 @@