Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

grunt sass sourcemaps sass wrong path?

Tags:

sass

gruntjs

I have a grunt project set up but I'm missing the sourcemap for sass. The style.css.map looks like this:

{
"version": 3,
"file": "style.css",
"sources": [
    "../style.scss",
    "../_general.scss",
    "../_align.scss",
    "../_cf.scss",
    "../_fixed-fluid.scss"
],
"sourcesContent": [],
"mappings": "ACAA;EACI,AAAQ;EACR,AAAS;;AAGb;EACI,AAAY;;AAGhB;EACI,AAAe;;AAGnB;EACI,AAAU;EACd,AAAe;IACP,AAAS;IACT,AAAS;IACT,AAAQ;IACR,AAAY;IACZ,AAAU;IACV,AAAM;IACN,AAAO;IACP,AAAQ;;AAIhB;EACI,AAAS;;AC3Bb;EACE,AAAU;EACV,AAAQ;EACR,AAAY;;AAGd;EACE,AAAU;EACV,AAAK;EACL,AAAM;EACN,AAAW;;AAIb;EACI,AAAS;EACT,AAAO;EACP,AAAY;;AAGhB;EACI,AAAS;EACT,AAAY;EACZ,AAAgB;EAChB,AAAQ;;AAIZ;EACI,AAAY;EACZ,AAAQ;EACR,AAAW;EACf,AAAgB;IACR,AAAS;IACT,AAAS;IACT,AAAQ;IACR,AAAgB;;AAIxB;EACI,AAAS;EACT,AAAgB;;AC3CpB,AAAG;EACC,AAAS;EACT,AAAS;;ACFb;EACI,AAAO;EACP,AAAO;EACP,AAAY;;AAGhB;EACI,AAAO;EACP,AAAO;;AAIX;EACI,AAAO;EACP,AAAY;EACZ,AAAO;EACP,AAAc",
"names": []

}

The 'sources' path is incorrect. It should be "../sass/style.scss" instead of "../style.scss"

Grunt project file:

module.exports = function(grunt) {
    require('jit-grunt')(grunt);

    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),
        connect: {
            server: {
                options: {
                    port: 9000,
                    livereload: true,
                    keepalive: true,
                    open: true,
                    hostname: 'localhost'
                }
            }
        },
        sass: {
            options: {
                sourceMap: true,
                sourceMapEmbed: true
            },
            dist: {
                files: {
                    'dist/style.css': 'assets/sass/style.scss'
                },
                outputStyle: 'expanded'
            }
        },
        autoprefixer: {
            single_file: {
                src: 'dist/style.css'
            }
        },
        watch: {
            options: {
                spawn: false,
                livereload: true,
            },
            sass: {
                files: ['assets/sass/*.scss'],
                tasks: ['sass', 'autoprefixer']
            },
            html: {
                files: ['index.html', 'views/*.html'],
            },
            js: {
                files: ['assets/js/*.js']
            }
        },
    });
};

Anyone know how to configure this sourcemap path correctly in my gruntfile? Thank you!

like image 854
Lukk1989 Avatar asked Aug 11 '26 16:08

Lukk1989


1 Answers

Source maps have been f***ed in grunt-sass for a while, since version v.18.0 (node-sass v2) I think. I am patiently waiting for the downstream changes from libsass > node-sass to make their way to grunt-sass soon. Node-sass v3 should fix these issues.

I suggest reverting back to version v0.17.0 of grunt-sass so source maps work again

like image 127
Zander Avatar answered Aug 13 '26 17:08

Zander



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!