0

when i upadate webpack from 4 to 5, the error existed.

ERROR in   Error: F:\cloud-music\public\index.html:13
  module.exports = __webpack_require__.p + "static/media/javascript,__webpack_public_path__ = htmlWebpackPluginPublicPath;.93bce551.bin";
  ^
  ReferenceError: module is not defined

however, when i look into the index.html, there is no any module index.html

please the error message more detail

here is how i defined the htmlWebpackPlugin

           new HtmlWebpackPlugin(
                Object.assign({}, {
                        inject: true,
                        template: paths.appHtml,
                    },
                    isEnvProduction ? {
                        minify: {
                            removeComments: true,
                            collapseWhitespace: true,
                            removeRedundantAttributes: true,
                            useShortDoctype: true,
                            removeEmptyAttributes: true,
                            removeStyleLinkTypeAttributes: true,
                            keepClosingSlash: true,
                            minifyJS: true,
                            minifyCSS: true,
                            minifyURLs: true,
                        },
                    } :
                    undefined
                )

thank you! Dmitry Nesterenko please check my code, I'm new in webpack

{
      loader: require.resolve('file-loader'),
      exclude: [/\.(js|mjs|jsx|ts|tsx)$/, /\.json$/], 
      // was ---- exclude: [/\.(js|mjs|jsx|ts|tsx)$/, /\.html$/, /\.json$/],
      options: {
            name: 'static/media/[name].[hash:8].[ext]',
      },
},

I changed the code as above, however, i didn't work. And when I remove all of them, it worked! I don't know why???

4

1 回答 1

1

It's a plugin's bug. Fix described in this Issue:

https://github.com/jantimon/html-webpack-plugin/issues/1589

于 2021-02-10T02:55:26.773 回答