我重写了sass-loader配置以包含node_modules路径:
// config/webpack/environment.js
const { environment } = require('@rails/webpacker')
environment.loaders.prepend('sass', {
test: /\.(css|scss|sass)$/,
use: [{
loader: 'style-loader'
}, {
loader: 'css-loader'
}, {
loader: 'sass-loader',
options: {
includePaths: ['node_modules'],
}
}]
})
module.exports = environment
Webpack编译没有错误,但它不再输出application.css包。
我做了更改,因为我从我的Sass文件导入的NPM插件从其他插件导入代码时导致编译错误。
答案 0 :(得分:4)
找到解决方案:
environment.loaders.get('sass').use.find(item => item.loader === 'sass-loader').options.includePaths = ['node_modules']