Skip to content

Commit 553f050

Browse files
committed
feat: externals引入的js lib也加上crossorigin.
1 parent 3197be6 commit 553f050

2 files changed

Lines changed: 25 additions & 13 deletions

File tree

lib/builder.js

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -500,19 +500,31 @@ class Builder {
500500
* @private
501501
*/
502502
static _setExternalPlugin(externals) {
503-
return new HtmlWebpackExternalsPlugin({
504-
externals: externals || [
505-
{
506-
module: 'react',
507-
entry: 'https://11.url.cn/now/lib/15.1.0/react-with-addons.min.js?_bid=3123',
508-
global: 'React'
509-
},
510-
{
511-
module: 'react-dom',
512-
entry: 'https://11.url.cn/now/lib/15.1.0/react-dom.min.js?_bid=3123',
513-
global: 'ReactDOM'
503+
const newExternals = externals || [
504+
{
505+
module: 'react',
506+
entry: 'https://11.url.cn/now/lib/15.1.0/react-with-addons.min.js?_bid=3123',
507+
global: 'React'
508+
},
509+
{
510+
module: 'react-dom',
511+
entry: 'https://11.url.cn/now/lib/15.1.0/react-dom.min.js?_bid=3123',
512+
global: 'ReactDOM'
513+
}
514+
];
515+
516+
// 增加 cross-origin 的头
517+
newExternals.map((external) => {
518+
external.entry = {
519+
path: external.entry,
520+
attributes: {
521+
crossorigin: 'anonymous'
514522
}
515-
]
523+
}
524+
});
525+
526+
return new HtmlWebpackExternalsPlugin({
527+
externals: newExternals
516528
});
517529
}
518530

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "builder-webpack3",
3-
"version": "0.2.17",
3+
"version": "0.2.18",
44
"description": "webpack项目构建器.",
55
"main": "lib/index.js",
66
"scripts": {

0 commit comments

Comments
 (0)