Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setting custom path for sourcemap file #209

Open
mscarchilli opened this issue Aug 12, 2015 · 10 comments
Open

Setting custom path for sourcemap file #209

mscarchilli opened this issue Aug 12, 2015 · 10 comments

Comments

@mscarchilli
Copy link

Would you please add this as a feature for the sourcemap options in a future release? Thank you!

@liquidmetal
Copy link

I think we should have the .map file at the same location as the generated CSS file. This keeps things consistent and the configuration easier to read.

...
    files: {
        'some/path/custom.css': 'another/path/file.scss'
    } 
...

This should generate some/path/custom.css and some/path/custom.css.map.

@mscarchilli
Copy link
Author

This will not always work depending on the project you are working on and how it is organized. Being able to set the path for the sourcemap is more useful. This way you get the best of both worlds. Default could be the same location as the CSS, but add the option to set it to another. Some other Grunt plugins already have this ability.

@liquidmetal
Copy link

Okay - so the .map should be generated at the same location as the CSS by default - but we need some mechanism to put .map files in another location.

@liquidmetal
Copy link

I looked into this for a bit today and here are my findings.

grunt-contrib-sass depends on Ruby's sass executable. Version 3.4 of this executable has support for generating sourcemaps - but no way to specify the location of the .map file. This means we're limited by the original script and not this plugin.

The other plugins use the C/C++ libsass which supports writing the map to a different location.


To get the sourceMapDest property for this plugin working, we would have to move the generated map to the specified destination after sass finishes execution.

liquidmetal added a commit to liquidmetal/grunt-contrib-sass that referenced this issue Sep 24, 2015
@liquidmetal
Copy link

Here's what I have right now:

module.exports = function(grunt) {

  grunt.initConfig({
    sass: {
        options: {
            sourcemap: 'auto',
            sourcemapDest: 'something/other/'
        },
        dist: {
            files: {
                'something/test.css': 'custom.scss'
            }
        }
    }
  });

  grunt.loadNpmTasks('grunt-contrib-sass');

  grunt.registerTask('default', ['sass']);
};

custom.scss is parsed and something/test.css is generated. The sourcemap something/test.css.map is also generated at the same time. The plugin then notices you've set sourcemapDest - so it moves the .map file to this directory.

Potential issue: The file something/test.css needs to be updated with the new sourcemap path. This can be resolved by running the css file through a find & replace operation.


Is this a good way to solve this issue?

@sindresorhus
Copy link
Member

This should be fixed in Ruby Sass, not here. → https://github.com/sass/sass/issues/new

@mscarchilli
Copy link
Author

Looks good so far. @sindresorhus , which aspect of all of this should be fixed in Ruby Sass?

@sindresorhus
Copy link
Member

Setting custom path for sourcemap file

@liquidmetal
Copy link

I exposed a file name flag in the sass binary on my local machine. Let's see if this gets accepted into Sass.
liquidmetal/sass@5bfe9cc

If it does, we can have a new parameter: sourcemapFilename that contains the output map file name.

@liquidmetal
Copy link

Awaiting on sass/sass#1844 to proceed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants