From 464582ded6a5a26c00b425e34a8260cbbabef027 Mon Sep 17 00:00:00 2001 From: tjz <415800467@qq.com> Date: Wed, 21 Mar 2018 21:16:11 +0800 Subject: [PATCH] add version --- antd-tools/getWebpackConfig.js | 4 ++-- components/index.js | 17 +++++++++++++++++ components/version/index.js | 3 +++ components/version/style/index.js | 2 ++ index.js | 28 ++++++++++++++++++++++++++++ package.json | 2 +- 6 files changed, 53 insertions(+), 3 deletions(-) create mode 100644 components/version/index.js create mode 100644 components/version/style/index.js create mode 100644 index.js diff --git a/antd-tools/getWebpackConfig.js b/antd-tools/getWebpackConfig.js index 1646f1034..c8c69f707 100644 --- a/antd-tools/getWebpackConfig.js +++ b/antd-tools/getWebpackConfig.js @@ -153,7 +153,7 @@ module.exports = function (modules) { new webpack.BannerPlugin(` ${distFileBaseName} v${pkg.version} -Copyright 2017-present, vue-antd-ui, Inc. +Copyright 2017-present, vue-antd-ui. All rights reserved. `), new webpack.ProgressPlugin((percentage, msg, addInfo) => { @@ -170,7 +170,7 @@ All rights reserved. } if (process.env.RUN_ENV === 'PRODUCTION') { - const entry = ['./components/index'] + const entry = ['./index'] config.entry = { [`${distFileBaseName}.min`]: entry, } diff --git a/components/index.js b/components/index.js index e0c6d11af..116ea51af 100644 --- a/components/index.js +++ b/components/index.js @@ -1,3 +1,18 @@ +/* @remove-on-es-build-begin */ +// this file is not used if use https://github.com/ant-design/babel-plugin-import +const ENV = process.env.NODE_ENV +if (ENV !== 'production' && + ENV !== 'test' && + typeof console !== 'undefined' && + console.warn && + typeof window !== 'undefined') { + console.warn( + 'You are using a whole package of antd, ' + + 'please use https://www.npmjs.com/package/babel-plugin-import to reduce app bundle size.', + ) +} +/* @remove-on-es-build-end */ + import Button from './button' const ButtonGroup = Button.Group export { Button, ButtonGroup } @@ -105,3 +120,5 @@ export { default as Calendar } from './calendar' import DatePicker from './date-picker' const { MonthPicker, RangePicker, WeekPicker } = DatePicker export { DatePicker, MonthPicker, RangePicker, WeekPicker } + +export { default as version } from './version' diff --git a/components/version/index.js b/components/version/index.js new file mode 100644 index 000000000..671c9474a --- /dev/null +++ b/components/version/index.js @@ -0,0 +1,3 @@ +import { version } from '../../package.json' + +export default version diff --git a/components/version/style/index.js b/components/version/style/index.js new file mode 100644 index 000000000..c0c81c9c4 --- /dev/null +++ b/components/version/style/index.js @@ -0,0 +1,2 @@ +// empty file prevent babel-plugin-import error +import '../../style/index.less' diff --git a/index.js b/index.js new file mode 100644 index 000000000..1ccd73fe0 --- /dev/null +++ b/index.js @@ -0,0 +1,28 @@ +/* eslint no-console:0 */ +function camelCase (name) { + return name.charAt(0).toUpperCase() + + name.slice(1).replace(/-(\w)/g, (m, n) => { + return n.toUpperCase() + }) +} + +// Just import style for https://github.com/ant-design/ant-design/issues/3745 +const req = require.context('./components', true, /^\.\/[^_][\w-]+\/style\/index\.js?$/) + +req.keys().forEach((mod) => { + let v = req(mod) + if (v && v.default) { + v = v.default + } + const match = mod.match(/^\.\/([^_][\w-]+)\/index\.js?$/) + if (match && match[1]) { + if (match[1] === 'message' || match[1] === 'notification') { + // message & notification should not be capitalized + exports[match[1]] = v + } else { + exports[camelCase(match[1])] = v + } + } +}) + +module.exports = require('./components') diff --git a/package.json b/package.json index 1b8d8a088..e0f2e8556 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "vue-antd-ui", - "version": "0.1.0", + "version": "0.1.1", "title": "Ant Design Vue", "description": "An enterprise-class UI design language and Vue-based implementation", "keywords": [