mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
fix: change utils && mixins alias
This commit is contained in:
parent
711352ae12
commit
72d590d890
19
.babelrc
19
.babelrc
@ -1,12 +1,9 @@
|
||||
{
|
||||
"presets": [
|
||||
[
|
||||
"es2015",
|
||||
{ "modules": false }
|
||||
]
|
||||
],
|
||||
"plugins": [
|
||||
"transform-vue-jsx",
|
||||
"external-helpers"
|
||||
]
|
||||
}
|
||||
"presets": [["es2015", { "modules": false }]],
|
||||
"plugins": ["transform-vue-jsx", "transform-runtime"],
|
||||
"env": {
|
||||
"utils": {
|
||||
"presets": [["es2015", { "modules": "commonjs" }]]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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'
|
||||
});
|
@ -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();
|
||||
|
@ -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;
|
||||
});
|
||||
|
@ -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')
|
||||
|
@ -53,7 +53,7 @@ export default {
|
||||
}
|
||||
</script>
|
||||
|
||||
## ActionSheet 行动按钮
|
||||
## Actionsheet 行动按钮
|
||||
|
||||
### 代码演示
|
||||
|
||||
@ -106,11 +106,11 @@ export default {
|
||||
```
|
||||
:::
|
||||
|
||||
#### 带取消按钮的ActionSheet
|
||||
#### 带取消按钮的 Actionsheet
|
||||
|
||||
如果传入了`cancelText`属性,且不为空,则会在下方显示一个取消按钮,点击会将当前`ActionSheet`关闭。
|
||||
如果传入了`cancelText`属性,且不为空,则会在下方显示一个取消按钮,点击会将当前`Actionsheet`关闭。
|
||||
|
||||
:::demo 带取消按钮的ActionSheet
|
||||
:::demo 带取消按钮的 Actionsheet
|
||||
```html
|
||||
<van-button @click="show2 = true">弹出带取消按钮的actionsheet</van-button>
|
||||
<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
|
||||
<van-button @click="show3 = true">弹出带标题的actionsheet</van-button>
|
||||
<van-actionsheet v-model="show3" title="支持以下配送方式" class="title-actionsheet">
|
||||
@ -170,10 +170,11 @@ export default {
|
||||
| title | 标题 | `String` | | |
|
||||
| cancelText | 取消按钮文案 | `String` | | |
|
||||
| overlay | 是否显示遮罩 | `Boolean` | | |
|
||||
| closeOnClickOverlay | 点击遮罩是否关闭`ActionSheet` | `Boolean` | | |
|
||||
| closeOnClickOverlay | 点击遮罩是否关闭`Actionsheet` | `Boolean` | | |
|
||||
|
||||
### actions
|
||||
|
||||
|
||||
`API`中的`actions`为一个对象数组,数组中的每一个对象配置每一列,每一列有以下`key`:
|
||||
|
||||
| key | 说明 |
|
||||
|
@ -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)
|
||||
|
@ -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",
|
||||
|
@ -34,7 +34,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import Popup from 'src/mixins/popup';
|
||||
import Popup from 'packages/mixins/popup';
|
||||
import VanLoading from 'packages/loading';
|
||||
import VanIcon from 'packages/icon';
|
||||
|
||||
|
@ -24,8 +24,8 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {once} from 'src/utils/dom';
|
||||
import Clickoutside from 'src/utils/clickoutside';
|
||||
import {once} from 'packages/utils/dom';
|
||||
import Clickoutside from 'packages/utils/clickoutside';
|
||||
|
||||
export default {
|
||||
name: 'van-cell-swipe',
|
||||
|
@ -23,7 +23,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import findParent from 'src/mixins/findParent';
|
||||
import findParent from 'packages/mixins/findParent';
|
||||
|
||||
export default {
|
||||
name: 'van-checkbox',
|
||||
|
@ -1,6 +1,6 @@
|
||||
import Vue from 'vue';
|
||||
import Dialog from './dialog.vue';
|
||||
import merge from 'src/utils/merge';
|
||||
import merge from 'packages/utils/merge';
|
||||
|
||||
const DialogConstructor = Vue.extend(Dialog);
|
||||
|
||||
|
@ -18,7 +18,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import Popup from 'src/mixins/popup';
|
||||
import Popup from 'packages/mixins/popup';
|
||||
|
||||
const CANCEL_TEXT = '取消';
|
||||
const CONFIRM_TEXT = '确定';
|
||||
|
@ -12,7 +12,7 @@
|
||||
|
||||
<script>
|
||||
import Vue from 'vue';
|
||||
import Popup from 'src/mixins/popup';
|
||||
import Popup from 'packages/mixins/popup';
|
||||
import VanSwipe from 'packages/swipe';
|
||||
import VanSwipeItem from 'packages/swipe-item';
|
||||
|
||||
|
@ -14,7 +14,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import translateUtil from 'src/utils/transition';
|
||||
import translateUtil from 'packages/utils/transition';
|
||||
import draggable from './draggable';
|
||||
|
||||
const DEFAULT_ITEM_HEIGHT = 44;
|
||||
|
@ -7,7 +7,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import Popup from 'src/mixins/popup';
|
||||
import Popup from 'packages/mixins/popup';
|
||||
export default {
|
||||
name: 'van-popup',
|
||||
|
||||
|
@ -25,7 +25,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import findParent from 'src/mixins/findParent';
|
||||
import findParent from 'packages/mixins/findParent';
|
||||
|
||||
export default {
|
||||
name: 'van-radio',
|
||||
|
@ -21,7 +21,7 @@
|
||||
|
||||
<script>
|
||||
import VanIcon from 'packages/icon';
|
||||
import Clickoutside from 'src/utils/clickoutside';
|
||||
import Clickoutside from 'packages/utils/clickoutside';
|
||||
|
||||
export default {
|
||||
name: 'van-search',
|
||||
|
@ -42,7 +42,7 @@
|
||||
|
||||
<script>
|
||||
import swipe from './swipe';
|
||||
import translateUtil from 'src/utils/transition';
|
||||
import translateUtil from 'packages/utils/transition';
|
||||
|
||||
export default {
|
||||
name: 'van-tabs',
|
||||
|
@ -1,5 +1,5 @@
|
||||
import Vue from 'vue';
|
||||
import merge from 'src/utils/merge';
|
||||
import merge from 'packages/utils/merge';
|
||||
import ToastComponent from './toast.vue';
|
||||
|
||||
const ToastConstructor = Vue.extend(ToastComponent);
|
||||
|
@ -1,4 +1,4 @@
|
||||
import Utils from 'src/utils/scroll.js';
|
||||
import Utils from 'packages/utils/scroll.js';
|
||||
|
||||
const CONTEXT = '@@Waterfall';
|
||||
const OFFSET = 300;
|
||||
|
@ -790,13 +790,20 @@ babel-register@^6.24.1:
|
||||
mkdirp "^0.5.1"
|
||||
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"
|
||||
resolved "https://registry.yarnpkg.com/babel-runtime/-/babel-runtime-6.25.0.tgz#33b98eaa5d482bb01a8d1aa6b437ad2b01aec41c"
|
||||
dependencies:
|
||||
core-js "^2.4.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:
|
||||
version "6.25.0"
|
||||
resolved "https://registry.yarnpkg.com/babel-template/-/babel-template-6.25.0.tgz#665241166b7c2aa4c619d71e192969552b10c071"
|
||||
|
Loading…
x
Reference in New Issue
Block a user