Skip to content

Commit 333c48c

Browse files
committed
fix: cdn dayjs error, close #5874
1 parent e79dd35 commit 333c48c

File tree

4 files changed

+55
-16
lines changed

4 files changed

+55
-16
lines changed

antd-tools/getWebpackConfig.js

+9-7
Original file line numberDiff line numberDiff line change
@@ -216,14 +216,16 @@ All rights reserved.
216216

217217
if (process.env.RUN_ENV === 'PRODUCTION') {
218218
const entry = ['./index'];
219-
config.externals = {
220-
vue: {
221-
root: 'Vue',
222-
commonjs2: 'vue',
223-
commonjs: 'vue',
224-
amd: 'vue',
219+
config.externals = [
220+
{
221+
vue: {
222+
root: 'Vue',
223+
commonjs2: 'vue',
224+
commonjs: 'vue',
225+
amd: 'vue',
226+
},
225227
},
226-
};
228+
];
227229
config.output.library = distFileBaseName;
228230
config.output.libraryTarget = 'umd';
229231
config.optimization = {

site/src/vueDocs/introduce.en-US.md

+13-2
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,19 @@ We provide `antd.js` `antd.css` and `antd.min.js` `antd.min.css` under `ant-desi
6666

6767
> **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.
6868
69-
> Note: you should import [dayjs](https://day.js.org/) before using antd.js.
69+
> Note: you should import [dayjs](https://day.js.org/) and dayjs plugins before using antd.js.
70+
71+
Like:
72+
73+
```html
74+
<script src="https://unpkg.com/dayjs/dayjs.min.js"></script>
75+
<script src="https://unpkg.com/dayjs/plugin/customParseFormat.js"></script>
76+
<script src="https://unpkg.com/dayjs/plugin/weekday.js"></script>
77+
<script src="https://unpkg.com/dayjs/plugin/localeData.js"></script>
78+
<script src="https://unpkg.com/dayjs/plugin/weekOfYear.js"></script>
79+
<script src="https://unpkg.com/dayjs/plugin/weekYear.js"></script>
80+
<script src="https://unpkg.com/dayjs/plugin/advancedFormat.js"></script>
81+
```
7082

7183
## Usage
7284

@@ -128,7 +140,6 @@ import 'ant-design-vue/dist/antd.css'; // or 'ant-design-vue/dist/antd.less'
128140
};
129141
```
130142

131-
132143
## Links
133144

134145
- [Home Page](https://www.antdv.com/)

site/src/vueDocs/introduce.zh-CN.md

+13-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,19 @@ $ yarn add ant-design-vue
6666

6767
> **强烈不推荐使用已构建文件**,这样无法按需加载,而且难以获得底层依赖模块的 bug 快速修复支持。
6868
69-
> 注意:引入 antd.js 前你需要自行引入 [dayjs](https://day.js.org/)
69+
> 注意:引入 antd.js 前你需要自行引入 [dayjs](https://day.js.org/) 及其相关插件。
70+
71+
如:
72+
73+
```html
74+
<script src="https://unpkg.com/dayjs/dayjs.min.js"></script>
75+
<script src="https://unpkg.com/dayjs/plugin/customParseFormat.js"></script>
76+
<script src="https://unpkg.com/dayjs/plugin/weekday.js"></script>
77+
<script src="https://unpkg.com/dayjs/plugin/localeData.js"></script>
78+
<script src="https://unpkg.com/dayjs/plugin/weekOfYear.js"></script>
79+
<script src="https://unpkg.com/dayjs/plugin/weekYear.js"></script>
80+
<script src="https://unpkg.com/dayjs/plugin/advancedFormat.js"></script>
81+
```
7082

7183
## 示例
7284

webpack.build.conf.js

+20-6
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,26 @@ function addLocales(webpackConfig) {
4141
}
4242

4343
function externalDayjs(config) {
44-
config.externals.dayjs = {
45-
root: 'dayjs',
46-
commonjs2: 'dayjs',
47-
commonjs: 'dayjs',
48-
amd: 'dayjs',
49-
};
44+
config.externals.push({
45+
dayjs: {
46+
root: 'dayjs',
47+
commonjs2: 'dayjs',
48+
commonjs: 'dayjs',
49+
amd: 'dayjs',
50+
},
51+
});
52+
config.externals.push(function ({ _context, request }, callback) {
53+
if (/^dayjs\/plugin\//.test(request)) {
54+
const name = request.replaceAll('/', '_');
55+
return callback(null, {
56+
root: name,
57+
commonjs2: name,
58+
commonjs: name,
59+
amd: name,
60+
});
61+
}
62+
callback();
63+
});
5064
}
5165

5266
function injectWarningCondition(config) {

0 commit comments

Comments
 (0)