Skip to content
wait until externals loaded.
JavaScript
Branch: master
Clone or download
Latest commit 7de3da0 Aug 1, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
demo update: demo Aug 1, 2019
.gitignore 1.0.0 Jul 9, 2019
README.md Update README.md Jul 31, 2019
package.json fix #1 Aug 1, 2019
wait-external-webpack-plugin.js fix #1 Aug 1, 2019

README.md

wait-external-webpack-plugin

相关文章

《Webpack 打包后代码执行时机分析与优化》

Description

通过对 entry 文件进行处理,业务逻辑将等待所依赖的 externals 文件加载完成后再开始执行。避免 externals 文件未加载完成或加载失败时,直接执行业务逻辑导致异常。

Install

npm i -D wait-external-webpack-plugin

Usage

const WaitExternalPlugin = require('wait-external-webpack-plugin');

module.exports = {
    entry: {
        pageA: "./src/pageA.js",
        pageB: "./src/pageB.js"
    },
    externals: [
        {
            jquery: 'window jQuery',
        },
        {
            react : ['React', 'subtract']
        }
    ],
    plugins: [
        new WaitExternalPlugin({
            test: /\.js$/,  // 正则匹配需要处理的 entry,默认对所有 entry 进行处理
        }),
    ]
};
You can’t perform that action at this time.