0

我正在将继承的 Webpack 配置从 v.3.8.1 升级到 v4.43.0,并且在最新版本中遇到了异步加载块文件的奇怪问题。我的 Webpack 输出目录结构如下所示:

- webpack.config.js
- web
- <backend_python_app>
- frontend
-- src
-- static
--- webpack
---- scripts
----- app_1
----- app_2

在 v3.8.1 中,我有一个供应商捆绑包,/static/webpack/scripts/vendor.js它从static/webpack/<chunkname>.splitbundle.js. 但是,当我更新配置并将 Webpack 版本升级到 v4.43.0 时,供应商捆绑包会尝试从webpack/<chunkname>.splitbundle.js. 不知何故,早期版本的 Webpack 能够动态发现(据我所知)static块的前缀,但最新版本不能。我不知道如何配置 v4.43.0 来复制这种行为。

v3.8.1 Webpack 配置:

{
    entry: {<entries>},
    output: {
        filename: "[name].[hash].js",
        chunkFilename: "[name].splitbundle.[hash].js",
        path: path.resolve(__dirname, "static/webpack"),
        publicPath: "webpack/"
    },
    resolve: {
        extensions: [".js", ".json", ".coffee", ".coat", ".ts", ".tsx"],
        alias: {
            "static/images": path.join(__dirname, "./static/images")
        }
    },
    plugins: [
        new webpack.optimize.CommonsChunkPlugin({
            names: [
                "base",
                "vendor"
            ],
            filename: "scripts/ts/[name].[hash].js",
            minChunks: Infinity
        })
    ]
}

v4.43.0 Webpack 配置:

{
    entry: {<entries>},
    output: {
        filename: "[name].[hash].js",
        chunkFilename: "[name].splitbundle.[hash].js",
        path: path.resolve(__dirname, "static/webpack"),
        publicPath: "webpack/"
    },
    resolve: {
        extensions: [".js", ".json", ".coffee", ".coat", ".ts", ".tsx"],
        alias: {
            "static/images": path.join(__dirname, "./static/images")
        }
    }
}

4

0 回答 0