fix: cdn dayjs error, close #5874

pull/5879/head
tangjinzhou 2022-08-07 15:10:53 +08:00
parent e79dd3508c
commit 333c48c6ba
4 changed files with 55 additions and 16 deletions

View File

@ -216,14 +216,16 @@ All rights reserved.
if (process.env.RUN_ENV === 'PRODUCTION') {
const entry = ['./index'];
config.externals = {
vue: {
root: 'Vue',
commonjs2: 'vue',
commonjs: 'vue',
amd: 'vue',
config.externals = [
{
vue: {
root: 'Vue',
commonjs2: 'vue',
commonjs: 'vue',
amd: 'vue',
},
},
};
];
config.output.library = distFileBaseName;
config.output.libraryTarget = 'umd';
config.optimization = {

View File

@ -66,7 +66,19 @@ We provide `antd.js` `antd.css` and `antd.min.js` `antd.min.css` under `ant-desi
> **We strongly discourage loading the entire files** this will add bloat to your application and make it more difficult to receive bugfixes and updates. Antd is intended to be used in conjunction with a build tool, such as [webpack](https://webpack.github.io/), which will make it easy to import only the parts of antd that you are using.
> Note: you should import [dayjs](https://day.js.org/) before using antd.js.
> Note: you should import [dayjs](https://day.js.org/) and dayjs plugins before using antd.js.
Like:
```html
<script src="https://unpkg.com/dayjs/dayjs.min.js"></script>
<script src="https://unpkg.com/dayjs/plugin/customParseFormat.js"></script>
<script src="https://unpkg.com/dayjs/plugin/weekday.js"></script>
<script src="https://unpkg.com/dayjs/plugin/localeData.js"></script>
<script src="https://unpkg.com/dayjs/plugin/weekOfYear.js"></script>
<script src="https://unpkg.com/dayjs/plugin/weekYear.js"></script>
<script src="https://unpkg.com/dayjs/plugin/advancedFormat.js"></script>
```
## Usage
@ -128,7 +140,6 @@ import 'ant-design-vue/dist/antd.css'; // or 'ant-design-vue/dist/antd.less'
};
```
## Links
- [Home Page](https://www.antdv.com/)

View File

@ -66,7 +66,19 @@ $ yarn add ant-design-vue
> **强烈不推荐使用已构建文件**,这样无法按需加载,而且难以获得底层依赖模块的 bug 快速修复支持。
> 注意:引入 antd.js 前你需要自行引入 [dayjs](https://day.js.org/)。
> 注意:引入 antd.js 前你需要自行引入 [dayjs](https://day.js.org/) 及其相关插件。
如:
```html
<script src="https://unpkg.com/dayjs/dayjs.min.js"></script>
<script src="https://unpkg.com/dayjs/plugin/customParseFormat.js"></script>
<script src="https://unpkg.com/dayjs/plugin/weekday.js"></script>
<script src="https://unpkg.com/dayjs/plugin/localeData.js"></script>
<script src="https://unpkg.com/dayjs/plugin/weekOfYear.js"></script>
<script src="https://unpkg.com/dayjs/plugin/weekYear.js"></script>
<script src="https://unpkg.com/dayjs/plugin/advancedFormat.js"></script>
```
## 示例

View File

@ -41,12 +41,26 @@ function addLocales(webpackConfig) {
}
function externalDayjs(config) {
config.externals.dayjs = {
root: 'dayjs',
commonjs2: 'dayjs',
commonjs: 'dayjs',
amd: 'dayjs',
};
config.externals.push({
dayjs: {
root: 'dayjs',
commonjs2: 'dayjs',
commonjs: 'dayjs',
amd: 'dayjs',
},
});
config.externals.push(function ({ _context, request }, callback) {
if (/^dayjs\/plugin\//.test(request)) {
const name = request.replaceAll('/', '_');
return callback(null, {
root: name,
commonjs2: name,
commonjs: name,
amd: name,
});
}
callback();
});
}
function injectWarningCondition(config) {