Importing CSS from node_modules with Gulp-SASS
I want to import CSS file from mine node_modules
using SASS.
@import 'normalize.css/normalize';
This is how mine gulpfile.js
handles my SASS:
const
gulp = require('gulp'),
sass = require('gulp-sass');
gulp.task('sass', function () {
return gulp.src(['source/assets/css/**.scss', '!source/assets/css/**/_*.[scss|sass'])
.pipe(sass())
.pipe(gulp.dest('output/assets/css'));
});
SASS compiler won't import css from node_modules. It will throw an error instead.
Error: File to import not found or unreadable: normalize.css/normalize.
+3
source to share
1 answer
The SASS compiler doesn't know where to look for files. Location is required.
gulp.task('sass', function () {
return gulp.src(['source/assets/css/**.scss', '!source/assets/css/**/_*.[scss|sass'])
.pipe(sass({
includePaths: ['node_modules']
}))
.pipe(gulp.dest('output/assets/css'));
});
+4
source to share