在config文件夹中的webpack.config.dev.js文件中,我尝试添加加载程序,以便我的.scss文件可以处理:
{
test: /\.css$/,
use: [
require.resolve('style-loader'),
{
loader: require.resolve('css-loader'),
options: {
importLoaders: 1,
},
},
{
loader: require.resolve('postcss-loader'),
options: {
// Necessary for external CSS imports to work
ident: 'postcss',
plugins: () => [
require('postcss-flexbugs-fixes'),
autoprefixer({
browsers: [
'>1%',
'last 4 versions',
'Firefox ESR',
'NOT IE < 9', // React doesn't support IE8 anyway
],
flexbox: 'no-2009',
}),
],
},
},
],
},
{
test: /\.scss$/,
loaders: [
require.resolve('style-loader'),
require.resolve('css-loader'),
require.resolve('sass-loader')
]
},
但是,出现以下错误...
无法编译。
./ src / index.scss(./node_modules/css-loader??ref--6-oneOf-5-1!./node_modules/postcss-loader/src??postcss!.//node_modules/sass- loader / lib / loader.js!./ src / index.scss) ReferenceError:未定义autoprefixer
有人可以帮忙吗?