Answer the question
In order to leave comments, you need to log in
Why doesn't Gulp autoprefixer work with sourcemaps?
When starting the style task from
const gulp = require('gulp'),
sass = require('gulp-sass'),
sourcemaps = require('gulp-sourcemaps'),
autoprefixer = require('gulp-autoprefixer'),
browsersync = require('browser-sync').create();
function style() {
return gulp.src('./source/sass/style.scss')
.pipe(sourcemaps.init())
.pipe(sass().on('error', sass.logError))
.pipe(sourcemaps.write('./maps'))
.pipe(autoprefixer({cascade: true}))
.pipe(gulp.dest('./build/css/'))
.pipe(browsersync.stream());
};
function watch() {
browsersync.init({
server: {
baseDir: './build/'
},
port: 3000,
notify: false
});
gulp.watch('./source/sass/**/*.scss', style);
gulp.watch('./source/*.html').on('change', gulp.series(browsersync.reload));
gulp.watch('./source/js/**/*.js').on('change', gulp.series(browsersync.reload));
};
exports.style = style;
exports.watch = watch;
{
"name": "Project",
"version": "1.0.0",
"description": "MyNewProject",
"main": "gulpfile.js",
"dependencies": {},
"devDependencies": {
"browser-sync": "^2.26.3",
"gulp": "^4.0.2",
"gulp-autoprefixer": "^6.1.0",
"gulp-sass": "^4.0.2",
"gulp-sourcemaps": "^2.6.5",
"gulp-watch": "^5.0.1",
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
},
"browserslist": [
"since 2015",
"IE 10"
],
"author": "Fedya",
"license": "ISC"
}
Answer the question
In order to leave comments, you need to log in
function style() {
return gulp.src('./source/sass/style.scss')
.pipe(sourcemaps.init())
.pipe(sass().on('error', sass.logError))
.pipe(autoprefixer({cascade: true}))
.pipe(sourcemaps.write('./maps'))
.pipe(gulp.dest('./build/css/'))
.pipe(browsersync.stream());
};
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question