Нere是我的webpack.config.js:
我运行npm后运行手表
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
module.exports = {
mode: 'production',
entry: './catalog/view/theme/default/sas/common.scss',
plugins: [
new MiniCssExtractPlugin({
// Options similar to the same options in webpackOptions.output
// both options are optional
filename: "./catalog/view/theme/default/stylesheet/stylesheet.css",
})
],
module: {
rules: [
{
test: /\.scss$/,
use: [
MiniCssExtractPlugin.loader,
{
loader: "css-loader",
options: {
modules: true,
sourceMap: true,
importLoader: 2
}
},
'postcss-loader',
"sass-loader"
],
}
]
}
,
watch: true,
}
我已经阅读了很多示例,但仍然感到困惑-没有一个是行不通的。
答案 0 :(得分:0)
已通过添加配置解决了该问题:
output: {
path: path.resolve(__dirname, "catalog/view/theme/default/css"),
},
我没有注意到带有css的文件已保存到'./src/.../catalog/view/theme/default/sas/common.scss'文件夹中,因此“ output.path”是强制性财产。