-
Notifications
You must be signed in to change notification settings - Fork 60
Source maps referring to complied css instead of SASS files #88
Comments
Sounds like Autoprefixer can't find previous source maps from grunt-sass. Could you post your options for grunt-sass and grunt-autoprefixer and your file structure please? |
File Structure:
|
I came here to report the same problem. Here's my file structure: And my gruntfile sass and autoprefixer setup:
|
I have exactly the same problem. And both sass and autoprefixer are configured to use sourcemaps. It seems that only few selectors are mapped fine to SCSS and rest of selectors are reffering to compiled CSS. Is it possible then BEM methodology for can broke it? Because I'm using syntax like this
|
I couldn't reproduce the issue. Here is my setup: http://cl.ly/001w090D1f33/ga-88.zip cd into downloaded directory and run |
I had older grunt-autoprefixer 2.0.0. So I did update and now I'm running on 2.2.0. But problem is still here. Let me show you my testing project (it's blank templated generated by Yeoman).
Autoprefixer is included in Gruntfile by default. You can see that some CSS selectors are referring to complied css. Only some a few definitions are referring to SCSS file (_type.scss) If I remove whole autoprefixer definition form my Gruntfile and restart |
Ok I see now, in the map from libsass we have:
And then after Autoprefixer run:
So app.scss becomes app.css though it shouldn't. @ai any ideas why this is happening? PostCSS gets |
I think we has some CSS path problem. This can be happend when by some reasom |
I'm experiencing the same issue. Any progress so far? |
I had this issue too. After installation of old version grunt-sass (0.16.1 instead 0.18.0) everything worked. It's strange, because sourcemap from grunt-sass 0.18.0 worked wIthout autoprefixer. |
@LostSenSS thanks, this helped. Looks like everybody here is using grunt-sass then. I investigated the difference between 0.16.1 and 0.18.0 and also grunt-contrib-sass using the file structure above and here it is: 0.16.1
0.18.0
contrib
As you can see either grunt-sass or node-sass has dropped the relative paths to the sources for some reason and Autoprefixer cannot find them and update. I didn't try it myself, but I guess enabling inline sourcemaps ( |
I am having the same problem: package.json:
Gruntfile.js
Would it solve the problem if there was an option telling autoprefixer to keep the sourcemap-comment at the end of the file and do not do anything with the comment or the sourcemap? |
a hack but i fixed my same issue by compiling my sass to css with a dist of "prestyles.css" and then ran the autoprefixer on the sass dist to create my final compile to "styles.css" this does create two compileds css files and maps but i was having the same issue and sunk too much time on this to get scss mappings with auto prefixing. |
So what is the result of this research? It will be better to use |
Sorry, I am using |
BTW, PostCSS has many plugins. You can do nested, variables and mixins by pure PostCSS (Autoprefixer is just a PostCSS plugin). So you can replace Sass and have perfect source map and fastest gulp (PostCSS is 3 times faster that libsass). |
Check that there aren't any unicode characters in your sass. libsass adds without @charset
with @charset
tested with |
Hm, by removing all UTF-8 references and verifying that there is no UTF-8 comment at the beginning of my CSS files, I still have the wrong line numbers. They are off by some 5-10 lines (which ist better than nothing, but still) Setup: @JacobDorman: sorry ;) |
Ahh, the plot thickens :) We might be dealing with multiple issues. @charset was definitely causing my problem. Removing the character fixes the sourcemaps. Test repo here: https://github.com/JacobDorman/libsass-autoprefixer-test/ |
Here's something interesting. I noticed that if I ran my grunt-sass task, the line references from the map were incorrect. Opening the map file, I noticed a bunch of extra semicolons... If I manually removed them, the references were fixed. So, just to test it out, I manually removed those semicolons and then re-ran autoprefixer. The problem was fixed! So the stem of this issue for me is in grunt-sass, but moreso, Libsass itself. I've opened a ticket there we can follow. |
I'm working with Gulp, but I'm having the exact same issue as being described here. The styles.map.css looks fine, except that it only shows the first module, and then loads the generated styles.css file. I'm using gulp-sass with autoprefixer. I'm not sure how to solve this, as I am unfamiliar with gulp/sass. I've tried the solutions in this thread (the ones that I understood) but nothing works so far. |
For me, disabling/downgrading Browserify solved the issue... are you using this plugin? Does removing it help in any way? |
I think I'm also having this issue. The map comment is at the end of my generated .css file, autoprefixer says the map file is generated, and yet no browser displays line references at all. Interestingly, if I have my grunt config like this:
It writes the out file to /src and /src.map. If I also add a dest, it saves |
Had this issue too but upgrading to grunt-postcss fixed. The note for "How to migrate from grunt-autoprefixer?" made it super easy. Shoutout to @nDmitry for making such a seamless transition. Really appreciate it! |
But there is one disadvantage. It's not possible to easy migrate from SCSS to PostCSS just with switching of preprocessor to postprocessor. Both technologies need different approach from the beginning of whole frontend development. If I have big project, it takes some time to rewrite my code. Good info is, that I'll just use PostCSS in future for another new project |
@martinpesout I thought that at first too, but it's not true. For example, I use Compass on all of my projects. Then I just have a Grunt task to run PostCSS on top of it:
I just add that to If you want, I can throw together a repo to give you the full picture. But yeah, PostCSS for me is just icing on my SCSS cake. |
I also have this problem if I add |
@tannerhodges I never though about this way of usage. I was thinking only about writing everything in preprocessor or only in postprocessor. Combining both together can be also useful 👍 |
I found this thread while looking for an answer to the same problem. I am using gulp and have my setup where I have different levels of scss/css manipulation. The most basic is to convert the scss to css for use in the browser during routine development. Second I use autoprefixer to prepare for cross-browser compatability. And finally I use a minification plugin to prep for deployment. I was running sourcemaps on both my first and second stages of development and when reviewing the error messages I noticed that autoprefixer was looking at the previous map (which some posters have referred to). By commenting out the creation of the map in the first stage, I realized I could avoid the error. And so finally, I simply added a delete statement to my second stage to dump the first map before running autoprefixer and now my flow is flowing again. This is acceptable because what ever level of dev or testing I am at I only need the map relating to that stage so any previous ones would be useless later on. Hopes this helps somebody out. Here is my code so folks can review for clarity: gulp.task('prefix', ['compileSass'], function() { gulp.task('cssmin', ['prefix'], function() { gulp.task('devStyles', ['cssmin'], function() { }) |
@icarlosmendez thank you for your explanation on how your gulpfile.js is working to build out your project. I integrated your solution into my build however decided to bundle it up a little more. Here's my solution. I have a task called Then I have the task I don't have Hope this helps someone else out. // prefixer and sourcemaps proj1
gulp.task('autoprefix_proj1',['proj1_styles'],function () {
del(['./site/css/main.css.map']);
return gulp.src('./site/indiv_project_pages/proj1/css/proj1_main.css')
.pipe(sourcemaps.init())
.pipe(postcss([ autoprefixer({ browsers: ['> 1%','last 2 versions'] }) ]))
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest(paths.project_pages_dest.proj1_dest.styles_proj1));
});
// Styles task for proj1
gulp.task('proj1_styles',function(){
// source to project 1 scss
return gulp.src(paths.source.project_pgs_src.proj_1.styles_proj1)
.pipe(plumber({
// plumber finds errors in stream
errorHandler: onError}))
.pipe(sourcemaps.init()) // source maps
.pipe(sass())
.pipe(gulp.dest(paths.project_pages_dest.proj1_dest.styles_proj1))
.pipe(cssmin()) // min css
.pipe(rename({ // rename file to site.min.css
suffix:'.min'
}))
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest(paths.project_pages_dest.proj1_dest.styles_proj1))
.pipe(notify({ message: 'proj1_styles task finished' }))
.pipe(browserSync.stream());
}); |
I use grunt-sass combined with autoprefixer.
When autoprefixer runs after the sass compiles, it creates the source map just fine, but when I view inspector, the source map is referring to the compiled sass file instead of the source sass itself
The text was updated successfully, but these errors were encountered: