Answer the question
In order to leave comments, you need to log in
What is the correct way to build a CSS file in Gulp, including files installed via NPM?
Hello.
I started learning Gulp to make it more convenient to work with layout and ran into a banal problem. For example, I install the normalize.css plugin via NPM. The corresponding directory appears in the /node_modules folder, there is a normalize.css file.
How to attach it to your project? Copying to the project folder or writing an absolute path seems inconvenient and, most likely, this is wrong.
The same applies to all CSS frameworks that are installed via NPM and that need to be attached to the project.
I found information about includePaths on the toaster: with an example, I tried to use it in a Gulp task:
gulp.task('sass', function() {
return gulp.src('app/sass/*.scss')
.pipe(sass( {
includePaths: require('normalize.css')
}))
.pipe(gulp.dest('app/css'))
});
@import 'normalize.css';
C:\Users\USER\Desktop\_project\node_modules\normalize.css\normalize.css:12
html {
^
SyntaxError: Unexpected token {
Answer the question
In order to leave comments, you need to log in
Understood. On the normalize.css part, there was an error on the line with IncludePaths, the correct one is here .
Regarding the part of the question on connecting frameworks - Bower decides everything, through it you can install different libraries. Information is in the lesson " Gulp for the little ones ", Bower is explained from ~53 minutes.
gulp.task('sass', function() {
return gulp.src('app/sass/*.scss')
.pipe(sass({
includePaths: ['./node_modules']
}))
.pipe(gulp.dest('app/css'))
});
@import 'normalize.css/normalize.css';
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question