M
M
Maksym Davydchuk2017-07-05 17:30:18
gulp.js
Maksym Davydchuk, 2017-07-05 17:30:18

Gulp-concat does not concatenate files, how to solve?

Hi all. There is gulpfile.js

var gulp = require('gulp'),
    useref = require('gulp-useref'),
    notify = require('gulp-notify'),
    scss = require('gulp-sass'),
    autoprefixer = require('gulp-autoprefixer'),
    csscomb = require('gulp-csscomb'),
    cssnano = require('gulp-cssnano'),
    rename = require('gulp-rename'),
    concat = require('gulp-concat'),
    uglify = require('gulp-uglifyjs'),
    image = require('gulp-image'),
    del = require('del'),
    browserSync = require('browser-sync').create();

gulp.task('serve', ['scss'], function () {
    browserSync.init({
        server: {
            baseDir: "./app"
        },
        notify: false
    });
    gulp.watch('app/scss/**/*.*', ['scss']);
    gulp.watch('app/*.html').on('change', browserSync.reload);
    gulp.watch('app/js/**/*.*').on('change', browserSync.reload);
});

gulp.task('scss', function () {
    return gulp.src('app/scss/main.scss')
        .pipe(scss()).on('error', notify.onError())
        .pipe(autoprefixer({
            browsers: ['last 15 versions'],
            cascade: false
        }))
        .pipe(gulp.dest('app/css'))
        .pipe(browserSync.stream());
});

gulp.task('csscomb', ['scss'], function () {
    return gulp.src('app/css/main.css')
        .pipe(csscomb('configs/yandex.json'))
        .pipe(gulp.dest('app/css'));
});

gulp.task('css', ['csscomb'], function () {
    return gulp.src('app/css/main.css')
        .pipe(cssnano())
        .pipe(rename({suffix: '.min'}))
        .pipe(gulp.dest('dist/css'));
});

gulp.task('scripts', function () {
    return gulp.src(['app/js/main.js', 'app/js/libs'])
        .pipe(concat('main.min.js'))
        .pipe(uglify({
            comments: false,
            mangle: true
        }))
        .pipe(gulp.dest('dist/js'));
});

gulp.task('img', function () {
    return gulp.src('app/img/**/*.*')
        .pipe(image())
        .pipe(gulp.dest('dist/img'));
});

gulp.task('clean', function () {
    return del.sync('dist/*');
});

gulp.task('useref', function () {
    return gulp.src('app/*.html')
        .pipe(useref())
        .pipe(gulp.dest('dist'));
});

gulp.task('build', ['clean', 'css', 'scripts', 'useref', 'img'], function () {
    var buildFonts = gulp.src('app/fonts/**/*.*')
        .pipe(gulp.dest('dist/fonts'));
});

gulp.task('default', ['serve']);

If I run the following scripts, I get main.min.js without concatenation (only app/js/main.js inside the file). What could be the problem? But if you run build everything works fine. Help find a solution to the problem. Gulp 3.9.1

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maksym Davydchuk, 2017-07-06
@maksym1991

Found the reason. Changed gulp.src(['app/js/main.js', 'app/js/libs']) to gulp.src(['app/js/main.js', 'app/js/libs /*. js '])

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question