Answer the question
In order to leave comments, you need to log in
In Gulp, one task does not start during assembly, what's the squiggle?
Hello! For the first time I got acquainted with the dropper, Gulp, that's how 2 days already, I decided to compile the first config, but 1 task does not work during assembly, I painted it below.
'use strict';
var gulp = require('gulp');
var sass = require('gulp-sass');
var minify = require('gulp-csso');
var uncss = require('gulp-uncss');
var htmlmin = require('gulp-htmlmin');
var uglify = require('gulp-uglify');
var postcss = require('gulp-postcss');
var mqpacker = require('css-mqpacker');
var autoprefixer = require('autoprefixer');
var sourcemaps = require('gulp-sourcemaps');
var rigger = require('gulp-rigger');
var plumber = require('gulp-plumber');
var rename = require('gulp-rename');
var imagemin = require('gulp-imagemin');
var svgmin = require('gulp-svgmin');
var svgstore = require('gulp-svgstore');
var run = require('run-sequence');
var del = require('del');
var browserSync = require('browser-sync').create();
gulp.task('html', function() {
gulp.src('src/*.html')
.pipe(rigger())
.pipe(htmlmin({collapseWhitespace: true}))
.pipe(gulp.dest('build'))
});
gulp.task('scss', function () {
gulp.src('src/scss/*.scss')
.pipe(plumber())
.pipe(sass({
outputStyle: 'expanded'
}))
.pipe(gulp.dest('build/css'));
});
// После того как сработал scss, хочу чтобы сработал styles, то есть добавил префикси, минифицировал
gulp.task('styles', function () {
gulp.src('build/css/*.css')
.pipe(plumber())
.pipe(sourcemaps.init())
.pipe(postcss([
autoprefixer({browsers: [
'last 2 versions'
]}),
mqpacker()
]))
.pipe(gulp.dest('build/css'))
.pipe(minify())
.pipe(rename({
suffix: '.min'
}))
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest('build/css'));
});
gulp.task('js', function() {
gulp.src('src/js/*.js')
.pipe(rigger())
.pipe(sourcemaps.init())
.pipe(uglify())
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest('build/js'));
});
gulp.task('images', function() {
return gulp.src('src/img/**/*.{png,jpg,gif}')
.pipe(imagemin([
imagemin.gifsicle(),
imagemin.optipng({optimizationLevel: 3}),
imagemin.jpegtran({progressive: true})
]))
.pipe(gulp.dest('build/img'));
});
gulp.task('icons', function() {
return gulp.src('src/img/icons/*.svg')
.pipe(svgmin())
.pipe(rename({prefix: 'icon-'}))
.pipe(svgstore({
inlineSvg: true
}))
.pipe(rename('icons.svg'))
.pipe(gulp.dest('build/img'));
});
gulp.task('fonts', function() {
return gulp.src('src/fonts/**/*')
.pipe(gulp.dest('build/fonts'));
});
gulp.task('server', function() {
browserSync.init({
server: 'build'
});
gulp.watch('src/**/*.html', ['html']);
gulp.watch('src/scss/**/*.scss', ['scss']);
gulp.watch('src/js/**/*.js', ['js']);
gulp.watch('build/**/*').on('change', browserSync.reload);
});
gulp.task('default', ['server']);
gulp.task('del', function() {
return del('build');
});
gulp.task('build', function (cb) {
run(
'del',
'html',
'scss',
'styles', // вот это добро не выводит результат, если запускать вручную, то есть gulp styles, после gulp build, то работает. Поставил плагин run-sequence.
'js',
'images',
'icons',
'fonts',
cb
);
});
Answer the question
In order to leave comments, you need to log in
I don't understand the meaning of this post? What does it make easy?
gulp.task('scss', function () {
gulp.src('src/scss/*.scss')
.pipe(plumber())
.pipe(sass({
outputStyle: 'expanded'
}))
.pipe(gulp.dest('build/css'));
});
// После того как сработал scss, хочу чтобы сработал styles, то есть добавил префикси, минифицировал
gulp.task('styles', function () {
gulp.src('build/css/*.css')
.pipe(plumber())
.pipe(sourcemaps.init())
.pipe(postcss([
autoprefixer({browsers: [
'last 2 versions'
]}),
mqpacker()
]))
.pipe(gulp.dest('build/css'))
.pipe(minify())
.pipe(rename({
suffix: '.min'
}))
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest('build/css'));
});
gulp.task('styles', function() {
gulp.src(src.sass)
.pipe(sass({
"sourcemap=none": true,
noCache: true,
compass: true,
style: sassStyle,
lineNumbers: sassComments
}))
.pipe(autoPrefixer())
.pipe(........................())
.pipe(gulp.dest(outputDir + 'css'))
.pipe(connect.reload())
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question