Reputation: 2968
I using Webpack to compile my SCSS files, based on simplest way:
module.exports = {
entry: './src/home.js',
output: {
filename: 'bundle.js',
path: path.resolve(__dirname, 'dist'),
},
module: {
rules: [
{
test: /\.scss$/,
use: [
'style-loader',
'css-loader',
'sass-loader',
]
}
]
}
};
Full content of src/home.js
file:
import 'library_name/src/assets/scss/styles.scss';
Fragment of styles.scss
has code like below:
@import '../../../node_modules/bootstrap/scss/bootstrap.scss';
So, when I run webpack
command then I get error message:
SassError: File to import not found or unreadable: ../../../node_modules/bootstrap/scss/bootstrap.scss.
on line 5 of ...\node_modules\library_name\src\assets\scss\styles.scss
Upvotes: 1
Views: 1478
Reputation: 8480
https://github.com/webpack-contrib/sass-loader#resolving-import-at-rules
So for bootstrap:
@import "~bootstrap/scss/bootstrap.scss";
Upvotes: 1