sass-loader
,所以它发生了
.css
.scss
.但是它总是输出CSS文件。
{
"dependencies": {
"css-loader": "^0.28.11",
"node-sass": "^4.9.0",
"sass-loader": "^7.0.3",
"webpack": "^4.12.0",
"style-loader": "^0.21.0",
"webpack-cli": "^3.0.3",
"mini-css-extract-plugin": "^0.4.0"
}
}
以下内容:
const path = require('path');
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
module.exports = {
entry: "./main.sass",
resolve: {
extensions: ['.sass', '.css'],
},
plugins: [new MiniCssExtractPlugin()],
module: {
rules: [
{
test: /\.sass$/,
use: [
MiniCssExtractPlugin.loader,
"css-loader",
"sass-loader?indentedSyntax",
]
},
{
test: /\.css$/,
use: [
MiniCssExtractPlugin.loader,
"css-loader",
"sass-loader",
]
},
],
},
};
(让我们看看如果SASS加载器面临未知扩展会发生什么情况):
.black {
background-color: black
}
以下内容:
.red {
background-color: red
}
body
@import "./a.fff"
@import "./b.css"
node ./node_modules/webpack/bin/webpack.js
.red {
background-color: red
}
body { }
body .black {
background-color: black; }
如你所见,
a.fff
css
body { }
body .black {
background-color: black; }
body .red {
background-color: red; }
有什么方法可以迫使Sass加载器受到威胁吗