Skip to content

在webpack打包阶段检测失效资源或者错误资源并替换(Detect and replace invalid or wrong resources in the webpack packaging phase)

Notifications You must be signed in to change notification settings

WarrenLee19/bundle-url-check-plugin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

Example

npm i bundle-url-check-loader -D
yarn add bundle-url-check-loader -D
pnpm i bundle-url-check-loader -D

js

const checkAUrlList = [
    "http://schemas.microsoft.com/office/excel/2006/main",
    "http://schemas.openxmlformats.org/officeDocument/2006/custom-properties",
    "https://zhihu.com",
];

for (let i = 0; i < 3; i++) {
    var a = document.createElement("a");
    a.setAttribute("href", checkAUrlList[i]);
    a.innerHTML='123s4';
    document.getElementById("body").appendChild(a);
}

webpack.config.js

module.exports = {
    ...
    module: {
      rules: [
          {
              test: /\.js$/,
              use:[{
                loader:"bundle-url-check-loader",
                options:{
                  url:'https://www.baidu.com',
                  reg:[/^http[s]{0,1}:\/\/schemas\.\S*/]
                }
              }],
          },
      ],
    },
    ...
   
};

or

chainConfig

config.module.rule('bundle-url').test(/\.js$/).options({
      url:'https://www.baidu.com',
        reg:[/^http[s]{0,1}:\/\/schemas\.\S*/]
    })

About

在webpack打包阶段检测失效资源或者错误资源并替换(Detect and replace invalid or wrong resources in the webpack packaging phase)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages