Hey! Are there any awesome, gulp - experienced people here who can help
me out with my gulpfile?
I have some issues when i want to compile
my main.scss file where i import all my .sass files since i want to write in sass
and not scss…
this is my current gulpfile.js :
const gulp = require('gulp')
const sass = require('gulp-sass')
const autoprefixer = require('gulp-autoprefixer')
const minifycss = require('gulp-minify-css')
const rename = require('gulp-rename')
const util = require('gulp-util')
const log = util.log
const browserSync = require('browser-sync').create()
gulp.task('sass', () => {
log("Generate CSS files " + (new Date()).toString())
gulp.src('sass/main.scss')
.pipe(sass())
.on('error', sass.logError)
.pipe(autoprefixer({
browsers: ['last 3 versions']
}))
.pipe(gulp.dest('css'))
.pipe(rename({ suffix: '.min' }))
.pipe(minifycss())
.pipe(gulp.dest('css'))
.pipe(browserSync.stream())
})
gulp.task('sync', () => {
browserSync.init({
server: './',
notify: false
})
gulp.watch(['sass/**'], ['sass'])
gulp.watch('*.html').on('change', browserSync.reload)
gulp.watch('pages/*.html').on('change', browserSync.reload)
gulp.watch('js/*.js').on('change', browserSync.reload)
})
gulp.task('default', ['sync'])
greets f
edit: solved!
(If someone wants to use it) => {
my new file everything works perfect now }
const gulp = require('gulp')
const sass = require('gulp-sass')
const autoprefixer = require('gulp-autoprefixer')
const minifycss = require('gulp-minify-css')
const rename = require('gulp-rename')
const util = require('gulp-util')
const log = util.log
const browserSync = require('browser-sync').create()
gulp.task('sass', () => {
log("Generate CSS files " + (new Date()).toString())
gulp.src('sass/main.scss')
.pipe(sass({
includePaths:['scss','sass'],
onError: browserSync.notify
}))
.on('error', sass.logError)
.pipe(autoprefixer({
browsers: ['last 3 versions']
}))
.pipe(gulp.dest('css'))
.pipe(rename({ suffix: '.min' }))
.pipe(minifycss())
.pipe(gulp.dest('css'))
.pipe(browserSync.stream())
})
gulp.task('sync', () => {
browserSync.init({
server: './',
notify: false
})
gulp.watch(['sass/**'], ['sass'])
gulp.watch('*.html').on('change', browserSync.reload)
gulp.watch('pages/*.html').on('change', browserSync.reload)
gulp.watch('js/*.js').on('change', browserSync.reload)
})
gulp.task('default', ['sync'])