简体   繁体   English

SASS / 源映射未加载嵌套结构

[英]SASS / source maps not loading with nested structures

I went from all the SASS files being in the same directory, to a nested structure as follows.我从位于同一目录中的所有 SASS 文件转到如下嵌套结构。 Now, when I inspect an element in chrome, it takes me to the incorrect source map.现在,当我检查 chrome 中的一个元素时,它会将我带到不正确的源映射。 For example, when I inspect a button, instead of going to the _buttons partial, it goes to a different random partial that is unrelated.例如,当我检查一个按钮时,它不会转到 _buttons 部分,而是转到另一个不相关的随机部分。 Anyone know why this is happening?有谁知道为什么会这样? Does something need to change in my gulp file?我的 gulp 文件需要更改吗?

在此处输入图片说明 在此处输入图片说明

在此处输入图片说明

You have *.scss files, but in your gulpjs config.input.sass.你有 *.scss 文件,但在你的 gulpjs config.input.sass 中。 May be wrong files format.可能是错误的文件格式。

I use compass and it looks like this我使用指南针,它看起来像这样

gulp.task('compass', function() {
    gulp.src(inputDir+'/*.'+fileType)
        .pipe(compass({
            css: outputDir,
            sass: inputDir,
            sourcemap: true
        }))
        .pipe(gulp.dest(outputDir))
        .pipe(connect.reload());
});

gulp-sass + gulp-sourcemaps

This is my working example.这是我的工作示例。 You can see generated main.css.map You need to install https://www.npmjs.com/package/gulp-sass https://www.npmjs.com/package/gulp-sourcemaps可以看到生成的 main.css.map 需要安装https://www.npmjs.com/package/gulp-sass https://www.npmjs.com/package/gulp-sourcemaps

https://www.npmjs.com/package/sass-module-importer https://www.npmjs.com/package/sass-module-importer

The issue had to do with how we were importing the sass and css files together in the main.scss file, and doing the copy of css files in the gulp file.这个问题与我们如何在 main.scss 文件中一起导入 sass 和 css 文件,以及如何在 gulp 文件中复制 css 文件有关。 The easiest solution was to include the sass-module-importer.最简单的解决方案是包含 sass-module-importer。 The gulp file is updated below with the final solution.下面用最终解决方案更新了 gulp 文件。 在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM