Answer the question
In order to leave comments, you need to log in
Connecting normalize.css with gulp?
I ask for help, please tell me in detail how I can include in the existing gulpfile nozmalize.css. I installed it via npm, but I can't figure out what changes to add to the gulpfile in order for everything to work. And if any other plugin I want to connect how to do it?
const gulp = require('gulp');
const sass = require('gulp-sass');
const browserSync = require('browser-sync').create();
function style() {
return gulp.src('./scss/**/*.scss')
.pipe(sass())
.pipe(gulp.dest('./css'))
.pipe(browserSync.stream())
}
function watch() {
browserSync.init({
server: {
baseDir: './'
}
})
gulp.watch('./scss/**/*scss', style);
gulp.watch('./*.html').on('change', browserSync.reload);
}
exports.style = style;
exports.watch = watch;
Answer the question
In order to leave comments, you need to log in
You can write a new task to include styles from different libraries:
First you need to install the 'gulp-concat' package and include it
const concat = require('gulp-concat');
gulp.task('css-libs', function(){
return gulp.src('node_modules/normalize.css/normalize.css')
.pipe(concat('_libs.scss'))
.pipe(gulp.dest('./scss'))
.pipe(browserSync.reload({stream: true}))
})
const gulp = require('gulp');
const sass = require('gulp-sass');
const postcss = require('gulp-postcss');
const postcssImport = require('postcss-import');
module.exports.css = () => {
return gulp
.src('./scss/**/*.scss')
.pipe(sass())
.pipe(postcss([postcssImport()]))
.pipe(gulp.dest('./css'));
};
@import 'normalize.css';
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question