diff --git a/.babelrc b/.babelrc
index f266b7fa1..9b6775200 100644
--- a/.babelrc
+++ b/.babelrc
@@ -1,12 +1,9 @@
{
- "presets": [
- [
- "es2015",
- { "modules": false }
- ]
- ],
- "plugins": [
- "transform-vue-jsx",
- "external-helpers"
- ]
-}
\ No newline at end of file
+ "presets": [["es2015", { "modules": false }]],
+ "plugins": ["transform-vue-jsx", "transform-runtime"],
+ "env": {
+ "utils": {
+ "presets": [["es2015", { "modules": "commonjs" }]]
+ }
+ }
+}
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-lib.js b/build/bin/build-lib.js
index 08155459a..09d99b5b2 100644
--- a/build/bin/build-lib.js
+++ b/build/bin/build-lib.js
@@ -3,11 +3,12 @@
* 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
+ * 8. 打包 JS 文件:vant.js && vant.min.js
*/
const fs = require('fs');
@@ -16,37 +17,32 @@ const components = require('../../components.json');
const chalk = require('chalk');
require('shelljs/global');
-// clean dir
+// 1. clean dir
log('Starting', 'clean');
exec('npm run clean --silent');
log('Finished', 'clean');
-// build entry
+// 2. build entry
log('Starting', 'build:entry');
exec('npm run build:file --silent');
log('Finished', 'build:entry');
-// lint
+// 3. 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');
-
-// build [component].js
+// 4. build [component].js
log('Starting', 'build:component');
exec('npm run build:components --silent');
log('Finished', 'build:component');
-// build vant-css
+// 5. build vant-css
log('Starting', 'build:vant-css');
exec('npm run build:vant-css --silent');
log('Finished', 'build:vant-css');
-// build style entrys
+// 6. build style entrys
log('Starting', 'build:style-entries');
Object.keys(components).forEach((componentName) => {
const dir = path.join(__dirname, '../../lib/', componentName, '/style');
@@ -61,11 +57,18 @@ Object.keys(components).forEach((componentName) => {
});
log('Finished', 'build:style-entries');
-// build utils
+// 7. build utils
log('Starting', 'build:utils');
-exec('npm run build:utils --silent');
+exec('cross-env BABEL_ENV=utils babel packages/utils --out-dir lib/utils');
+exec('cross-env BABEL_ENV=utils babel packages/mixins --out-dir lib/mixins');
log('Finished', 'build:utils');
+// 8. build vant.js
+log('Starting', 'build:vant');
+exec('npm run build:vant --silent');
+log('Finished', 'build:vant');
+
+
// helpers
function log(status, action, breakLine) {
const now = new Date();
diff --git a/build/rollup.config.lib.js b/build/rollup.config.lib.js
index 917656c56..bcc58c750 100644
--- a/build/rollup.config.lib.js
+++ b/build/rollup.config.lib.js
@@ -11,8 +11,8 @@ import componentsConfig from '../components.json';
const extensions = ['.js', '.vue'];
// 打包时排除 mixins、utils、其他组件
-const utilsPath = path.resolve(__dirname, '../packages/common/utils/');
-const mixinsPath = path.resolve(__dirname, '../packages/common/mixins/');
+const utilsPath = path.resolve(__dirname, '../packages/utils/');
+const mixinsPath = path.resolve(__dirname, '../packages/mixins/');
const external = [
...fs.readdirSync(utilsPath).map(item => path.resolve(utilsPath, item)),
...fs.readdirSync(mixinsPath).map(item => path.resolve(mixinsPath, item)),
@@ -22,7 +22,7 @@ const external = [
];
export default Object.keys(componentsConfig).map(component => {
- return {
+ const config = {
entry: componentsConfig[component],
targets: [
{
@@ -33,29 +33,33 @@ export default Object.keys(componentsConfig).map(component => {
external: [
'vue',
'vue-lazyload',
- path.resolve(__dirname, '../packages/common/mixins/popup/index.js'),
+ path.resolve(__dirname, '../packages/mixins/popup/index.js'),
...external
],
plugins: [
vue(),
filesize(),
- babel({
- externalHelpers: true
+ commonjs({
+ extensions
}),
resolve({
main: true,
jsnext: true,
extensions
}),
- commonjs({
- extensions
- }),
alias({
resolve: extensions,
- 'src/mixins': path.resolve(__dirname, '../packages/common/mixins'),
- 'src/utils': path.resolve(__dirname, '../packages/common/utils'),
packages: path.resolve(__dirname, '../packages')
})
]
};
+
+ // button 使用 jsx,需要借助 babel
+ if (component === 'button') {
+ config.plugins.unshift(babel({
+ runtimeHelpers: true
+ }));
+ }
+
+ return config;
});
diff --git a/build/webpack.config.dev.js b/build/webpack.config.dev.js
index 5e3ccf985..6b8a482da 100644
--- a/build/webpack.config.dev.js
+++ b/build/webpack.config.dev.js
@@ -38,8 +38,6 @@ module.exports = {
extensions: ['.js', '.vue', '.css'],
alias: {
vue: 'vue/dist/vue.runtime.esm.js',
- 'src/mixins': path.resolve(__dirname, '../packages/common/mixins'),
- 'src/utils': path.resolve(__dirname, '../packages/common/utils'),
packages: path.join(__dirname, '../packages'),
lib: path.join(__dirname, '../lib'),
components: path.join(__dirname, '../docs/src/components')
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/package.json b/package.json
index 47746ed11..49a93029a 100644
--- a/package.json
+++ b/package.json
@@ -14,9 +14,8 @@
"bootstrap": "yarn || npm i && cd ./packages/vant-css/ && yarn || npm i && cd ../../",
"dev": "npm run build:file && webpack-dev-server --inline --config build/webpack.config.dev.js --content-base ./",
"build:file": "node build/bin/build-entry.js",
- "build:utils": "cross-env BABEL_ENV=utils babel packages/common --out-dir lib/common --presets=es2015",
"build:components": "rollup -c ./build/rollup.config.lib.js --color",
- "build:vant-css": "gulp build --gulpfile packages/vant-css/gulpfile.js --color && cp -R packages/vant-css/lib/ lib/vant-css",
+ "build:vant-css": "gulp build --gulpfile packages/vant-css/gulpfile.js --color && mkdir lib/vant-css && cp -R packages/vant-css/lib/ lib/vant-css",
"build:vant": "cross-env NODE_ENV=production webpack --progress --hide-modules --color --config build/webpack.build.js && cross-env NODE_ENV=production webpack -p --progress --hide-modules --color --config build/webpack.build.js",
"deploy": "npm run deploy:docs && npm run deploy:cdn && gh-pages -d docs/dist --remote youzan && rimraf docs/dist",
"deploy:cdn": "superman cdn /zanui/vue docs/dist/*.js docs/dist/*.css",
@@ -41,6 +40,7 @@
"author": "youzanfe",
"license": "ISC",
"dependencies": {
+ "babel-runtime": "6.x",
"raf.js": "0.0.4",
"vue-lazyload": "^1.0.6"
},
@@ -60,7 +60,6 @@
"babel-plugin-transform-vue-jsx": "^3.5.0",
"babel-polyfill": "^6.23.0",
"babel-preset-es2015": "^6.16.0",
- "babel-runtime": "^6.25.0",
"babelrc-rollup": "^3.0.0",
"chai": "^4.1.1",
"cheerio": "^0.22.0",
diff --git a/packages/actionsheet/src/actionsheet.vue b/packages/actionsheet/src/actionsheet.vue
index 1c9117bf2..a2544e129 100644
--- a/packages/actionsheet/src/actionsheet.vue
+++ b/packages/actionsheet/src/actionsheet.vue
@@ -34,7 +34,7 @@