D
D
Dmitry2016-11-14 13:04:02
JavaScript
Dmitry, 2016-11-14 13:04:02

Why such a large js file size after gulp?

Good afternoon. I collect one js file from 3x: 2 libraries (jQuery and Materializ) and my file where I specify in what order to load them. jquery initial weight is 260kb, materializ is 300kb, my file is 132b. Why do I get a 1.5mb file as output?
Here is my gulp:

var gulp = require('gulp'),
    cssmin = require('gulp-minify-css'),
    prefixer = require('gulp-autoprefixer'),
    uglify = require('gulp-uglify'),
    sass = require('gulp-sass'),
    watch = require('gulp-watch'),
    sourcemaps = require('gulp-sourcemaps'),
    rigger = require('gulp-rigger');

var path = {
    build: {
        html: 'build/',
        js: 'build/js/',
        css: 'build/css/',
    },
    src: {
        html: 'src/*.html',
        js: 'src/js/main.js',
        style: 'src/style/main.scss',
    },
    watch: {
        html: 'src/**/*.html',
        js: 'src/js/**/*.js',
        style: 'src/style/**/*.scss',
   }
};

gulp.task('html:build', function () {
    gulp.src(path.src.html)
        .pipe(rigger())
        .pipe(gulp.dest(path.build.html));
});

gulp.task('js:build', function () {
    gulp.src(path.src.js)
        .pipe(rigger())
        .pipe(sourcemaps.init())
        .pipe(uglify())
        .pipe(sourcemaps.write())
        .pipe(gulp.dest(path.build.js));
});

gulp.task('style:build', function () {
    gulp.src(path.src.style)
        .pipe(sourcemaps.init())
        .pipe(sass())
        .pipe(prefixer())
        .pipe(cssmin())
        .pipe(sourcemaps.write())
        .pipe(gulp.dest(path.build.css));
});


gulp.task('build', [
    'html:build',
    'js:build',
    'style:build'
]);

gulp.task('watch', function () {
    watch([path.watch.html], function (event, cb) {
        gulp.start('html:build');
    });
    watch([path.watch.style], function (event, cb) {
        gulp.start('style:build');
    });
    watch([path.watch.js], function (event, cb) {
        gulp.start('js:build');
    });
});

gulp.task('default', ['build', 'watch']);

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey Andreev, 2016-11-14
@LazyTalent

Because sourcemaps

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question