I
I
Ilya Kochkin2018-11-18 10:46:53
gulp.js
Ilya Kochkin, 2018-11-18 10:46:53

Why is gulp sourcemap not writing the source path correctly?

The crux of the issue is there. 2 tasks

sass = require('gulp-sass'),
    autoprefixer = require('gulp-autoprefixer'),
    compress_img = require('gulp-tinypng-nokey'),
    cleanCSS = require('gulp-clean-css'),
    concat = require('gulp-concat'),

    SRC = 'catalog/view/theme/default/src',
    PRD = 'catalog/view/theme/default/production',

gulp.task('sass', function () {
    return gulp.src(SRC + '/scss/zzzz.scss')
        .pipe(sourcemaps.init())
        .pipe(sass({outputStyle: 'compressed'}).on('error', sass.logError))
        .pipe(autoprefixer(['last 3 versions'], {cascade: true}))
        .pipe(rename('main.css'))
        .pipe(cleanCSS())
        .pipe(sourcemaps.write('../../src/scss/'))
        .pipe(gulp.dest(PRD + '/css'));
});
gulp.task('css_libs', function () {
    return gulp.src(SRC+'/css/libs/*.css')
        .pipe(sourcemaps.init())
        .pipe(concat('libs.css'))
        .pipe(cleanCSS())
        .pipe(sourcemaps.write('../../src/css/libs/'))
        .pipe(gulp.dest(PRD + '/css'));
});

css_libs task - collects all css libraries into one libs.css file and sends them to the production / css folder,
and it throws the libs.css.map file along the path to the sources - this is done so that I can then change
css files from the browser on the fly , here is the output in the file libs.css /*# sourceMappingURL=../../src/css/libs/libs.css.map */ that is, with the paths, everything is ok
task sass - from the file zzzz.scss compiles main .css and throws it there in the production / css folder, but the main.css.map file gets dick, understand where this is what is output from main.css /*# sourceMappingURL=main.css.map */ that is, the main.css.map file located next to the main.css file, although I specify a different path in the task, I
attach the project structure
oZCziTIKaH8.jpg

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question