这种错误通常在使用Bootstrap时出现。原因是在webpack配置文件中未正确配置解析器。需要在webpack配置文件中添加以下代码:
const path = require('path');
const webpack = require('webpack');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
module.exports = {
entry: {
app: './src/app.js',
},
output: {
filename: '[name].js',
path: path.resolve(__dirname, 'dist'),
},
module: {
rules: [
{
test: /\.scss$/,
use: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: [
{
loader: 'css-loader',
options: {
sourceMap: true,
},
},
{
loader: 'sass-loader',
options: {
sourceMap: true,
includePaths: [path.resolve(__dirname, './node_modules/bootstrap/scss')],
},
},
],
}),
},
],
},
plugins: [
new webpack.optimize.CommonsChunkPlugin({
name: 'vendor',
minChunks: Infinity,
}),
new ExtractTextPlugin('[name].css'),
],
};
在这个配置文件中,我们已经正确地配置了解析器和加载器,以便Sass能够正确地编译。这个解决方法假设您已经安装了Bootstrap和相应的加载器。如果您遇到了其他问题,请先查看错误消息,查找有关以下标签的提示,以获得更多帮助:$spacers和ModuleBuildError。
上一篇:编译SASS失败
下一篇:编译Sass时出现网格错误。