Reputation: 313
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???
Upvotes: 0
Views: 5277
Reputation: 6779
I had:
{
loader: require.resolve('file-loader'),
exclude: [/\.(js|mjs|jsx|ts|tsx)$/, /\.html$/, /\.json$/],
options: {
name: `${buildMode.ASSET_PREFIX}[name].[hash:8].[ext]`,
esModule: false,
},
}
changing esModule to true fixed the issue fixed it for me:
{
loader: require.resolve('file-loader'),
exclude: [/\.(js|mjs|jsx|ts|tsx)$/, /\.html$/, /\.json$/],
options: {
name: `${buildMode.ASSET_PREFIX}[name].[hash:8].[ext]`,
esModule: true,
},
}
Upvotes: 0
Reputation: 26
It's a plugin's bug. Fix described in this Issue:
https://github.com/jantimon/html-webpack-plugin/issues/1589
Upvotes: 1