I overrode the sass-loader configuration to include the node_modules path:
// 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 compiles without errors, however it does not output an application.css pack anymore.
I made the change, because NPM plugins I imported from my Sass files who imported code from other plugins were causing errors when compiling.
Warning: LibSass and Node Sass are deprecated. While they will continue to receive maintenance releases indefinitely, there are no plans to add additional features or compatibility with any new CSS or Sass features. Projects that still use it should move onto Dart Sass.
sass-loader requires you to install either Dart Sass, Node Sass on your own (more documentation can be found below) or Sass Embedded. This allows you to control the versions of all your dependencies, and to choose which Sass implementation to use.
Found the solution:
environment.loaders.get('sass').use.find(item => item.loader === 'sass-loader').options.includePaths = ['node_modules']
Reference: https://github.com/rails/webpacker/blob/3-x-stable/docs/webpack.md
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With