S
S
Sergey2019-01-22 08:55:10
JavaScript
Sergey, 2019-01-22 08:55:10

How to pass sourcemap from one file to another?

Good day.
When updating my gulpfile, I ran into the following problem:
1 task collects all scss files from a folder into one, the ` gulp-concat ` plugin

const concatBlocks = () =>
    src(`${paths.blocks}**/*.scss`)
        .pipe(sourcemaps.init())
        .pipe(concat('_blocks.scss'))
        .pipe(sourcemaps.write())
        .pipe(dest(`${paths.scss.src}helpers/`));

2 task collects css using `gulp-sass`, importing the file prepared in the first task using SCSS, while generating a sourcemap using gulp-sourcemaps
const buildCss = () =>
    src(['*.scss', '!_*.scss', 'helpers/*.scss', '!helpers/_*.scss'], {cwd: paths.scss.src})
        .pipe(sourcemaps.init({loadMaps: true}))
        .pipe(scss().on('error', scss.logError))
        .pipe(sourcemaps.write('./maps'))
        .pipe(dest(`${paths.scss.built}`));

Naturally, with such an assembly in the sourcemap, all styles from `_blocks.scss`, collected in the first task, belong to it, and not to the original files. I would like to see information about the source files in the sourcemap. The `gulp-sourcemaps` documentation has an option `loadMaps: true`, which, as I understand it, should help me: I need to generate a map in the first task, and load it in the second, but it did not work.
Perhaps someone faced a similar problem?

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