I have tried almost every solution for the problem which includes.
giving type for use of
app.use(expre
I believe that the issue is due to the HtmlWebpackPlugin not providing the mimetype for the css file that has been injected with the MiniCssExtractPlugin. I've managed to solve the problem by using the HtmlWebpackLinkTypePlugin which should insert the mimetype into the css file.
/// top of file
const LinkTypePlugin = require('html-webpack-link-type-plugin').HtmlWebpackLinkTypePlugin;
....
const plugins = [
new CleanWebpackPlugin({
root: __dirname,
verbose: true,
dry: false
}),
new webpack.DefinePlugin({ 'process.env.NODE_ENV': '"production"' }),
new MiniCssExtractPlugin({ filename: "style.css", allChunks: false }),
new CopyWebpackPlugin([
{ from: './src/index.html', to: 'index.html' },
]),
new webpack.ProvidePlugin({
Promise: 'es6-promise-promise',
'React': 'react'
}),
new HtmlWebpackPlugin({
template: './src/index.html'
}),
new LinkTypePlugin({
'*.css' : 'text/css'
})
];
This should make your injected stylesheet line look like this:
Just a note that the *.css rule is a glob, so if your css file is hosted in a directory under your root, you will need to add something like **/*.css as your rule.
I hope this answers your question.