【发布时间】:2018-10-24 17:40:50
【问题描述】:
我目前正在尝试实现 mini-css-extract-plugin。
我未能实现哈希命名,当我使用它时,我不知道如何引导我的 index.html 文件即时获取特定名称。
如果有人有任何想法会很棒。谢谢
这里是我的 webpack.config.js:
plugins: [
new MiniCssExtractPlugin({
// Options similar to the same options in webpackOptions.output
// both options are optional
filename: 'styles.[contenthash].css'
})
],
module: {
rules: [ {
test: /\.js|jsx$/,
exclude: /node_modules/,
include: path.resolve(__dirname, "src"),
use: [
{
loader: "babel-loader",
options: {
presets: ["es2015", "stage-1", "react"]
}
}
]
},
{
test: /\.css$/,
use: [{
loader: MiniCssExtractPlugin.loader,
options: {
publicPath: "./public"
}
}, {
loader: "css-loader"
}]
}
]},
这里是我的 index.html:
<link rel="stylesheet" href="styles.css">
如何在我的 html 中翻译我的 css 文件名的“[contenthash]”部分?
【问题讨论】:
标签: css reactjs plugins webpack.config.js