MCEP Config
new MiniCssExtractPlugin({
filename: "css/[name].css",
})
Build directory
Abnormal
css/fonts/xx.woff"[name].css", it is normalSame problem
Extract-text-webpack-plugin has also encountered this problem before.
Setting publicPath to solve
use: ExtractTextPlugin.extract({
fallback: "style-loader",
publicPath: "../"
})
I also have the same problem. ExtractTextPlugin can set publicPath, so how should MiniCssExtractPlugin be set up?
@hfhanfei
The feeling is not very convenient, but it can solve the problem.
{
loader: MiniCssExtractPlugin.loader,
options: {
publicPath: "../"
}
}
@huzedong2015 output.publicPath for all webpack assets. Use output.publicPath + filename: 'my/path/to/css/style.css'
And never change publicPath and override in plugins/loaders if your don't know why you need this. Thanks!
@evilebottnawi
publicPath uses the default value (""),The following configuration of the CSS file resource path starts from css/, so the compiled CSS file resource path will have problems, requiring additional configuration publicPath.
new MiniCssExtractPlugin({
filename: "css/[name].css",
})
If the publicPath is set to an absolute path, or if the CSS file is placed in the root directory, no additional processing is required.but I do not want to deal with it.
{
output: {
publicPath: "/xxx"
}
}
// or
new MiniCssExtractPlugin({
filename: "[name].css",
})
Most helpful comment
@hfhanfei
The feeling is not very convenient, but it can solve the problem.