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

Sourcemaps #25

Closed
sindresorhus opened this issue Mar 13, 2013 · 35 comments
Closed

Sourcemaps #25

sindresorhus opened this issue Mar 13, 2013 · 35 comments

Comments

@sindresorhus
Copy link
Member

Add the sourcemap option when the feature lands in Sass stable.

@farneman
Copy link

I've tried testing this however for me it's failing with the following error:

Syntax error: Error generating source map: couldn't determine public URL for the source stylesheet.
No filename is available so there's nothing for the source map to link to.
on line of standard input

Looks like sass is not able to create the sourcemap since it's receiving from stdin rather than the file directly.

@sindresorhus
Copy link
Member Author

Hmm, yeah, makes sense. I'll need to remove the concat ability and use files directly.

@irskep
Copy link

irskep commented Apr 11, 2013

Just popping in to say I'd also like to see this feature.

@ehynds
Copy link

ehynds commented Apr 12, 2013

👍

@sindresorhus
Copy link
Member Author

#13 needs to be completed first.

@lmartins
Copy link

In my environment im able to create source maps if using the sass comand line commands, with grunt-contrib-sass doesn't seem to be possible at the moment.

@mattrc
Copy link

mattrc commented Apr 24, 2013

+1

sindresorhus added a commit that referenced this issue Jun 4, 2013
To be able to support Sourcemaps in the future and many other reasons.

No longer passes data using stdio, but instead uses real files.

Fixes #39 and enables #25
@curthasselschwert
Copy link

+1

1 similar comment
@bestander
Copy link

👍

@shama
Copy link
Member

shama commented Jun 6, 2013

Next person to +1 must write a PR implementing this feature.

@sindresorhus
Copy link
Member Author

👍

hah, it's already done. just waiting to merge in the open pr before I do a release.

@aaronbarker
Copy link

👍

1 similar comment
@steriley
Copy link

👍

@kevinwolfcr
Copy link

I'm really interested on this feature since I saw this article. Did anyone know when this will be implemented and ready for use?

@passy
Copy link

passy commented Jun 21, 2013

You can already enable sourcemaps by passing options: { sourcemap: true } into your task. dargs will just convert that to --sourcemap, which is everything you need to get started.

@jsoverson
Copy link
Member

On @passy's comment, it's worth noting that you also need the pre-release version of sass, installable via

gem install sass --pre

otherwise the sourcemap option fails.

@kevinwolfcr
Copy link

Thank you guys. It was my mistake, I hadn't the latest version of Sass.

@nissoh
Copy link

nissoh commented Jun 26, 2013

@passy can you post an example of your gruntfile?

i can't figure how dargs really works =\

@sindresorhus
Copy link
Member Author

@steriley
Copy link

@nissoh I found the easiest way to get it working is use the latest grunt-contrib-sass version from the repo.

Replace your grunt-contrib-sass dependency in package.json with this:

"grunt-contrib-sass": "git+https://github.com/gruntjs/grunt-contrib-sass.git#e85ee70ccb8839867172b57ca1378293291f8037"

Then add the task to your grunt file:

sass: {
  dev: {
    options: {
      sourcemap: true
    },
    files: {
      'app/css/article.css': 'app/scss/article.scss'
    }
  }
},

If you wish to use Compass with your project I'd also recommend just installing this version of Sass:
gem install sass -v 3.3.0.alpha.141 --pre

@sebastianekstrom
Copy link

@steriley I added the new grunt-contrib-sass dependency in my package.json, installed the latest SASS version and my task looks like this:

sass:
      dev:
        options:
          sourcemap: true
          trace: true
          require: ['./<%= pkg.directories.css %>/functions/sass-functions.rb']
          style: 'expanded'
        files:
          '<%= pkg.directories.css %>/styles__<%= pkg.version %>.css': '<%= pkg.directories.sass %>/styles.sass'

But I just get this error when I run grunt dev:

/Users/myname/.rvm/gems/ruby-2.0.0-p195/gems/sass-3.3.0.alpha.195/lib/sass/engine.rb:337:in `_render_with_sourcemap': Error generating source map: couldn't determine public URL for the source stylesheet. (Sass::SyntaxError)
  No filename is available so there's nothing for the source map to link to.

and

Warning: /Users/myname/.rvm/gems/ruby-2.0.0-p195/gems/sass-3.3.0.alpha.195/lib/sass/engine.rb:337:in `_render_with_sourcemap': Error generating source map: couldn't determine public URL for the source stylesheet. (Sass::SyntaxError)
  No filename is available so there's nothing for the source map to link to.

Any ideas?

@nissoh
Copy link

nissoh commented Jun 26, 2013

@steriley Thanks!

@jeffscottward
Copy link

Following @steriley 's recommendations, I got it to work!
Make sure to npm install after adding that specfic git repo to the package.json.
Problem though... the Sourcemaps syntax has changed!
The one that compiles is deprecated and uses the @ sign instead of # sign.

The error:
"//@ sourceMappingURL=" source mapping URL declaration is deprecated, "//# sourceMappingURL=" declaration should be used instead.

This says it has been fixed.
Maybe I need to use a newer version of sass then @steriley has suggested. Will try and update comment again.
sass/sass#804

@sindresorhus
Copy link
Member Author

Just published 0.4.0 which supports source maps.

@jeffscottward
Copy link

What versions of SASS and Compass should be installed?

I used 3.3.0-alpha-141, and on top of that,
a modified Engine.rb file for the correct /# syntax instead of /@

What should I roll back too?

@sindresorhus
Copy link
Member Author

See the sourcemap option in the readme.

@jeffscottward
Copy link

<3 oh youuuuuu

@lucascosta
Copy link

Hi, I'm on Windows 8, with ruby 2.0 and sass (3.3.0.alpha.134).

I can sucessfully generate source maps with

   sass --watch --sourcemap sass:css

In grunt, I've got this set:

    sass: {
        dist: {
          options: {
            sourcemap: true,
            trace: true,
            style: 'compact'
          },
          files: {
            'css/style.css': 'scss/style.scss'
          }
        },
    },

but no .map's are being generated. Any thoughts?

@mwq27
Copy link

mwq27 commented Jul 23, 2013

Same problem here, in the grunt task how do I specify the sourcemap urls?

Thanks

UPDATE: I just had to update the grunt-contrib-sass to 0.4.0, now it's working :)

@lmartins
Copy link

Sorry to dig up this issue again, Im running grunt-contrib-sass version 0.5.0, have the sourcemap option enabled and the --pre version of sass.

The source-maps are generated if I compile the css with sass --watch but using grunt-contrib-sass they don't get created.

Heres my grunt configuration:

    sass: {
        dist: {
            options: {
                sourcemap: true
            },
            files: {
                './dist/css/main.css': 'src/sass/main.scss'
            }
        }
    },

Any idea of what might be failing?

@jpdevries
Copy link

I'm on Sass 3.3.0.rc.1 (Maptastic Maple) and running grunt-contrib-sass ~0.5.0. I'm getting sourcemaps created, but they aren't working with Chrome. When I use sass directly to created the maps however, they work fine:
sass --scss --sourcemap index.scss:index.css

@jpdevries
Copy link

I figured out my issue, sorry for the false alarm. Looks like if you are running anything that modifies the CSS afterwards like cssmin it won't work. I know it seems odd to need to use cssmin since grunt-contrib-sass supports compression, but for this project we are using autoprefixer which expands it back out. Just needed to change my grunt tasks a bit and I'm golden.

@lmartins
Copy link

My issue had the same symptoms, but bit causes, I was using grunt connect with hostname "localhost", had to use my local IP to have sourcemaps loaded into Chrome devtools.

@jpdevries
Copy link

Is it possible to make this feature degrade gracefully? I'm noticing that if users aren't running Sass 3.3 they get a fatal error OptionParser::InvalidOption: invalid option: --sourcemap

if it's not possible, I'm wondering if there is a way to detect their version of sass from within the gruntfile and not include that property

@mscarchilli
Copy link

Updated to grunt-contrib-sass to 0.4.0 and now it's working. I wish I found this thread a lot sooner as it would have saved me from banging my head on the desk wondering why it wasn't working!

THANK YOU!

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