fix: change utils && mixins alias

This commit is contained in:
陈嘉涵 2017-08-15 17:27:02 +08:00
parent 711352ae12
commit 72d590d890
31 changed files with 76 additions and 92 deletions

View File

@ -1,12 +1,9 @@
{ {
"presets": [ "presets": [["es2015", { "modules": false }]],
[ "plugins": ["transform-vue-jsx", "transform-runtime"],
"es2015", "env": {
{ "modules": false } "utils": {
] "presets": [["es2015", { "modules": "commonjs" }]]
], }
"plugins": [ }
"transform-vue-jsx",
"external-helpers"
]
} }

View File

@ -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'
});

View File

@ -3,11 +3,12 @@
* Steps: * Steps:
* 1. 清理目录 * 1. 清理目录
* 2. 构建 JS 入口文件 * 2. 构建 JS 入口文件
* 3. 打包 JS 文件vant.js && vant.min.js * 3. 代码格式校验
* 4. 构建 CSS 文件vant-css * 4. 构建每个组件对应的 [component].js
* 5. 构建每个组件对应的 [component].js * 5. 构建 vant-css
* 6. 生成每个组件目录下的 style 入口 * 6. 生成每个组件目录下的 style 入口
* 7. 编译 utils * 7. 编译 utils
* 8. 打包 JS 文件vant.js && vant.min.js
*/ */
const fs = require('fs'); const fs = require('fs');
@ -16,37 +17,32 @@ const components = require('../../components.json');
const chalk = require('chalk'); const chalk = require('chalk');
require('shelljs/global'); require('shelljs/global');
// clean dir // 1. clean dir
log('Starting', 'clean'); log('Starting', 'clean');
exec('npm run clean --silent'); exec('npm run clean --silent');
log('Finished', 'clean'); log('Finished', 'clean');
// build entry // 2. build entry
log('Starting', 'build:entry'); log('Starting', 'build:entry');
exec('npm run build:file --silent'); exec('npm run build:file --silent');
log('Finished', 'build:entry'); log('Finished', 'build:entry');
// lint // 3. lint
log('Starting', 'lint'); log('Starting', 'lint');
exec('npm run lint --silent'); exec('npm run lint --silent');
log('Finished', 'lint'); log('Finished', 'lint');
// build vant.js // 4. build [component].js
log('Starting', 'build:vant');
exec('npm run build:vant --silent');
log('Finished', 'build:vant');
// build [component].js
log('Starting', 'build:component'); log('Starting', 'build:component');
exec('npm run build:components --silent'); exec('npm run build:components --silent');
log('Finished', 'build:component'); log('Finished', 'build:component');
// build vant-css // 5. build vant-css
log('Starting', 'build:vant-css'); log('Starting', 'build:vant-css');
exec('npm run build:vant-css --silent'); exec('npm run build:vant-css --silent');
log('Finished', 'build:vant-css'); log('Finished', 'build:vant-css');
// build style entrys // 6. build style entrys
log('Starting', 'build:style-entries'); log('Starting', 'build:style-entries');
Object.keys(components).forEach((componentName) => { Object.keys(components).forEach((componentName) => {
const dir = path.join(__dirname, '../../lib/', componentName, '/style'); const dir = path.join(__dirname, '../../lib/', componentName, '/style');
@ -61,11 +57,18 @@ Object.keys(components).forEach((componentName) => {
}); });
log('Finished', 'build:style-entries'); log('Finished', 'build:style-entries');
// build utils // 7. build utils
log('Starting', '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'); log('Finished', 'build:utils');
// 8. build vant.js
log('Starting', 'build:vant');
exec('npm run build:vant --silent');
log('Finished', 'build:vant');
// helpers // helpers
function log(status, action, breakLine) { function log(status, action, breakLine) {
const now = new Date(); const now = new Date();

View File

@ -11,8 +11,8 @@ import componentsConfig from '../components.json';
const extensions = ['.js', '.vue']; const extensions = ['.js', '.vue'];
// 打包时排除 mixins、utils、其他组件 // 打包时排除 mixins、utils、其他组件
const utilsPath = path.resolve(__dirname, '../packages/common/utils/'); const utilsPath = path.resolve(__dirname, '../packages/utils/');
const mixinsPath = path.resolve(__dirname, '../packages/common/mixins/'); const mixinsPath = path.resolve(__dirname, '../packages/mixins/');
const external = [ const external = [
...fs.readdirSync(utilsPath).map(item => path.resolve(utilsPath, item)), ...fs.readdirSync(utilsPath).map(item => path.resolve(utilsPath, item)),
...fs.readdirSync(mixinsPath).map(item => path.resolve(mixinsPath, item)), ...fs.readdirSync(mixinsPath).map(item => path.resolve(mixinsPath, item)),
@ -22,7 +22,7 @@ const external = [
]; ];
export default Object.keys(componentsConfig).map(component => { export default Object.keys(componentsConfig).map(component => {
return { const config = {
entry: componentsConfig[component], entry: componentsConfig[component],
targets: [ targets: [
{ {
@ -33,29 +33,33 @@ export default Object.keys(componentsConfig).map(component => {
external: [ external: [
'vue', 'vue',
'vue-lazyload', 'vue-lazyload',
path.resolve(__dirname, '../packages/common/mixins/popup/index.js'), path.resolve(__dirname, '../packages/mixins/popup/index.js'),
...external ...external
], ],
plugins: [ plugins: [
vue(), vue(),
filesize(), filesize(),
babel({ commonjs({
externalHelpers: true extensions
}), }),
resolve({ resolve({
main: true, main: true,
jsnext: true, jsnext: true,
extensions extensions
}), }),
commonjs({
extensions
}),
alias({ alias({
resolve: extensions, resolve: extensions,
'src/mixins': path.resolve(__dirname, '../packages/common/mixins'),
'src/utils': path.resolve(__dirname, '../packages/common/utils'),
packages: path.resolve(__dirname, '../packages') packages: path.resolve(__dirname, '../packages')
}) })
] ]
}; };
// button 使用 jsx需要借助 babel
if (component === 'button') {
config.plugins.unshift(babel({
runtimeHelpers: true
}));
}
return config;
}); });

View File

@ -38,8 +38,6 @@ module.exports = {
extensions: ['.js', '.vue', '.css'], extensions: ['.js', '.vue', '.css'],
alias: { alias: {
vue: 'vue/dist/vue.runtime.esm.js', 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'), packages: path.join(__dirname, '../packages'),
lib: path.join(__dirname, '../lib'), lib: path.join(__dirname, '../lib'),
components: path.join(__dirname, '../docs/src/components') components: path.join(__dirname, '../docs/src/components')

View File

@ -53,7 +53,7 @@ export default {
} }
</script> </script>
## ActionSheet 行动按钮 ## Actionsheet 行动按钮
### 代码演示 ### 代码演示
@ -106,11 +106,11 @@ export default {
``` ```
::: :::
#### 带取消按钮的ActionSheet #### 带取消按钮的 Actionsheet
如果传入了`cancelText`属性,且不为空,则会在下方显示一个取消按钮,点击会将当前`ActionSheet`关闭。 如果传入了`cancelText`属性,且不为空,则会在下方显示一个取消按钮,点击会将当前`Actionsheet`关闭。
:::demo 带取消按钮的ActionSheet :::demo 带取消按钮的 Actionsheet
```html ```html
<van-button @click="show2 = true">弹出带取消按钮的actionsheet</van-button> <van-button @click="show2 = true">弹出带取消按钮的actionsheet</van-button>
<van-actionsheet v-model="show2" :actions="actions1" cancel-text="取消"> <van-actionsheet v-model="show2" :actions="actions1" cancel-text="取消">
@ -149,11 +149,11 @@ export default {
``` ```
::: :::
#### 带标题的ActionSheet #### 带标题的 Actionsheet
如果传入了`title`属性,且不为空,则另外一种样式的`ActionSheet`,里面内容需要自定义。 如果传入了`title`属性,且不为空,则另外一种样式的`Actionsheet`,里面内容需要自定义。
:::demo 带标题的ActionSheet :::demo 带标题的 Actionsheet
```html ```html
<van-button @click="show3 = true">弹出带标题的actionsheet</van-button> <van-button @click="show3 = true">弹出带标题的actionsheet</van-button>
<van-actionsheet v-model="show3" title="支持以下配送方式" class="title-actionsheet"> <van-actionsheet v-model="show3" title="支持以下配送方式" class="title-actionsheet">
@ -170,10 +170,11 @@ export default {
| title | 标题 | `String` | | | | title | 标题 | `String` | | |
| cancelText | 取消按钮文案 | `String` | | | | cancelText | 取消按钮文案 | `String` | | |
| overlay | 是否显示遮罩 | `Boolean` | | | | overlay | 是否显示遮罩 | `Boolean` | | |
| closeOnClickOverlay | 点击遮罩是否关闭`ActionSheet` | `Boolean` | | | | closeOnClickOverlay | 点击遮罩是否关闭`Actionsheet` | `Boolean` | | |
### actions ### actions
`API`中的`actions`为一个对象数组,数组中的每一个对象配置每一列,每一列有以下`key` `API`中的`actions`为一个对象数组,数组中的每一个对象配置每一列,每一列有以下`key`
| key | 说明 | | key | 说明 |

View File

@ -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) ## [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) [Full Changelog](https://github.com/youzan/vant/compare/v0.6.2...v0.6.3)

View File

@ -14,9 +14,8 @@
"bootstrap": "yarn || npm i && cd ./packages/vant-css/ && yarn || npm i && cd ../../", "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 ./", "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: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: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", "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": "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", "deploy:cdn": "superman cdn /zanui/vue docs/dist/*.js docs/dist/*.css",
@ -41,6 +40,7 @@
"author": "youzanfe", "author": "youzanfe",
"license": "ISC", "license": "ISC",
"dependencies": { "dependencies": {
"babel-runtime": "6.x",
"raf.js": "0.0.4", "raf.js": "0.0.4",
"vue-lazyload": "^1.0.6" "vue-lazyload": "^1.0.6"
}, },
@ -60,7 +60,6 @@
"babel-plugin-transform-vue-jsx": "^3.5.0", "babel-plugin-transform-vue-jsx": "^3.5.0",
"babel-polyfill": "^6.23.0", "babel-polyfill": "^6.23.0",
"babel-preset-es2015": "^6.16.0", "babel-preset-es2015": "^6.16.0",
"babel-runtime": "^6.25.0",
"babelrc-rollup": "^3.0.0", "babelrc-rollup": "^3.0.0",
"chai": "^4.1.1", "chai": "^4.1.1",
"cheerio": "^0.22.0", "cheerio": "^0.22.0",

View File

@ -34,7 +34,7 @@
</template> </template>
<script> <script>
import Popup from 'src/mixins/popup'; import Popup from 'packages/mixins/popup';
import VanLoading from 'packages/loading'; import VanLoading from 'packages/loading';
import VanIcon from 'packages/icon'; import VanIcon from 'packages/icon';

View File

@ -24,8 +24,8 @@
</template> </template>
<script> <script>
import {once} from 'src/utils/dom'; import {once} from 'packages/utils/dom';
import Clickoutside from 'src/utils/clickoutside'; import Clickoutside from 'packages/utils/clickoutside';
export default { export default {
name: 'van-cell-swipe', name: 'van-cell-swipe',

View File

@ -23,7 +23,7 @@
</template> </template>
<script> <script>
import findParent from 'src/mixins/findParent'; import findParent from 'packages/mixins/findParent';
export default { export default {
name: 'van-checkbox', name: 'van-checkbox',

View File

@ -1,6 +1,6 @@
import Vue from 'vue'; import Vue from 'vue';
import Dialog from './dialog.vue'; import Dialog from './dialog.vue';
import merge from 'src/utils/merge'; import merge from 'packages/utils/merge';
const DialogConstructor = Vue.extend(Dialog); const DialogConstructor = Vue.extend(Dialog);

View File

@ -18,7 +18,7 @@
</template> </template>
<script> <script>
import Popup from 'src/mixins/popup'; import Popup from 'packages/mixins/popup';
const CANCEL_TEXT = '取消'; const CANCEL_TEXT = '取消';
const CONFIRM_TEXT = '确定'; const CONFIRM_TEXT = '确定';

View File

@ -12,7 +12,7 @@
<script> <script>
import Vue from 'vue'; import Vue from 'vue';
import Popup from 'src/mixins/popup'; import Popup from 'packages/mixins/popup';
import VanSwipe from 'packages/swipe'; import VanSwipe from 'packages/swipe';
import VanSwipeItem from 'packages/swipe-item'; import VanSwipeItem from 'packages/swipe-item';

View File

@ -14,7 +14,7 @@
</template> </template>
<script> <script>
import translateUtil from 'src/utils/transition'; import translateUtil from 'packages/utils/transition';
import draggable from './draggable'; import draggable from './draggable';
const DEFAULT_ITEM_HEIGHT = 44; const DEFAULT_ITEM_HEIGHT = 44;

View File

@ -7,7 +7,7 @@
</template> </template>
<script> <script>
import Popup from 'src/mixins/popup'; import Popup from 'packages/mixins/popup';
export default { export default {
name: 'van-popup', name: 'van-popup',

View File

@ -25,7 +25,7 @@
</template> </template>
<script> <script>
import findParent from 'src/mixins/findParent'; import findParent from 'packages/mixins/findParent';
export default { export default {
name: 'van-radio', name: 'van-radio',

View File

@ -21,7 +21,7 @@
<script> <script>
import VanIcon from 'packages/icon'; import VanIcon from 'packages/icon';
import Clickoutside from 'src/utils/clickoutside'; import Clickoutside from 'packages/utils/clickoutside';
export default { export default {
name: 'van-search', name: 'van-search',

View File

@ -42,7 +42,7 @@
<script> <script>
import swipe from './swipe'; import swipe from './swipe';
import translateUtil from 'src/utils/transition'; import translateUtil from 'packages/utils/transition';
export default { export default {
name: 'van-tabs', name: 'van-tabs',

View File

@ -1,5 +1,5 @@
import Vue from 'vue'; import Vue from 'vue';
import merge from 'src/utils/merge'; import merge from 'packages/utils/merge';
import ToastComponent from './toast.vue'; import ToastComponent from './toast.vue';
const ToastConstructor = Vue.extend(ToastComponent); const ToastConstructor = Vue.extend(ToastComponent);

View File

@ -1,4 +1,4 @@
import Utils from 'src/utils/scroll.js'; import Utils from 'packages/utils/scroll.js';
const CONTEXT = '@@Waterfall'; const CONTEXT = '@@Waterfall';
const OFFSET = 300; const OFFSET = 300;

View File

@ -790,13 +790,20 @@ babel-register@^6.24.1:
mkdirp "^0.5.1" mkdirp "^0.5.1"
source-map-support "^0.4.2" source-map-support "^0.4.2"
babel-runtime@^6.18.0, babel-runtime@^6.22.0, babel-runtime@^6.25.0: babel-runtime@^6.18.0, babel-runtime@^6.22.0:
version "6.25.0" version "6.25.0"
resolved "https://registry.yarnpkg.com/babel-runtime/-/babel-runtime-6.25.0.tgz#33b98eaa5d482bb01a8d1aa6b437ad2b01aec41c" resolved "https://registry.yarnpkg.com/babel-runtime/-/babel-runtime-6.25.0.tgz#33b98eaa5d482bb01a8d1aa6b437ad2b01aec41c"
dependencies: dependencies:
core-js "^2.4.0" core-js "^2.4.0"
regenerator-runtime "^0.10.0" regenerator-runtime "^0.10.0"
babel-runtime@^6.25.0:
version "6.25.0"
resolved "http://registry.npm.taobao.org/babel-runtime/download/babel-runtime-6.25.0.tgz#33b98eaa5d482bb01a8d1aa6b437ad2b01aec41c"
dependencies:
core-js "^2.4.0"
regenerator-runtime "^0.10.0"
babel-template@^6.24.1, babel-template@^6.25.0: babel-template@^6.24.1, babel-template@^6.25.0:
version "6.25.0" version "6.25.0"
resolved "https://registry.yarnpkg.com/babel-template/-/babel-template-6.25.0.tgz#665241166b7c2aa4c619d71e192969552b10c071" resolved "https://registry.yarnpkg.com/babel-template/-/babel-template-6.25.0.tgz#665241166b7c2aa4c619d71e192969552b10c071"