sass-loader: Invalid mapping: Negative column number
When running webpack -p
I am getting errors that appear to be related to producing sourcemaps. When i set sourceMap: false
for sass-loader
the build runs cleanly.
Stack trace follows:
Error: Invalid mapping: {"generated":{"line":1,"column":24989},"source":"webpack:///Work/Platform/Web/Web.App/assets/css/Work/Platform/Web/Web.App/Work/Platform/Web/Web.App/node_modules/bootstrap-sass/assets/stylesheets/bootstrap/mixins/_clearfix.scss","original":{"line":15,"column":-12},"name":null}
at SourceMapGenerator_validateMapping [as _validateMapping] (C:\Work\Platform\Web\Web.App\node_modules\source-map\lib\source-map-generator.js:277:13)
at SourceMapGenerator_addMapping [as addMapping] (C:\Work\Platform\Web\Web.App\node_modules\source-map\lib\source-map-generator.js:101:12)
at C:\Work\Platform\Web\Web.App\node_modules\source-map\lib\source-node.js:345:13
at SourceNode_walk [as walk] (C:\Work\Platform\Web\Web.App\node_modules\source-map\lib\source-node.js:224:9)
at SourceNode_walk [as walk] (C:\Work\Platform\Web\Web.App\node_modules\source-map\lib\source-node.js:220:13)
at SourceNode_walk [as walk] (C:\Work\Platform\Web\Web.App\node_modules\source-map\lib\source-node.js:220:13)
at SourceNode_toStringWithSourceMap [as toStringWithSourceMap] (C:\Work\Platform\Web\Web.App\node_modules\source-map\lib\source-node.js:336:8)
at ConcatSource.proto.sourceAndMap (C:\Work\Platform\Web\Web.App\node_modules\webpack-sources\lib\SourceAndMapMixin.js:28:32)
at Compilation.<anonymous> (C:\Work\Platform\Web\Web.App\node_modules\webpack\lib\SourceMapDevToolPlugin.js:57:32)
at Array.map (native)
at Compilation.<anonymous> (C:\Work\Platform\Web\Web.App\node_modules\webpack\lib\SourceMapDevToolPlugin.js:43:84)
at Array.forEach (native)
at Compilation.<anonymous> (C:\Work\Platform\Web\Web.App\node_modules\webpack\lib\SourceMapDevToolPlugin.js:42:11)
at Compilation.applyPlugins1 (C:\Work\Platform\Web\Web.App\node_modules\webpack\node_modules\tapable\lib\Tapable.js:75:14)
at self.applyPluginsAsync.err (C:\Work\Platform\Web\Web.App\node_modules\webpack\lib\Compilation.js:605:11)
at next (C:\Work\Platform\Web\Web.App\node_modules\webpack\node_modules\tapable\lib\Tapable.js:138:11)
at Compilation.compilation.plugin (C:\Work\Platform\Web\Web.App\node_modules\webpack\lib\optimize\UglifyJsPlugin.js:140:5)
at Compilation.applyPluginsAsyncSeries (C:\Work\Platform\Web\Web.App\node_modules\webpack\node_modules\tapable\lib\Tapable.js:142:13)
at self.applyPluginsAsync.err (C:\Work\Platform\Web\Web.App\node_modules\webpack\lib\Compilation.js:601:10)
at next (C:\Work\Platform\Web\Web.App\node_modules\webpack\node_modules\tapable\lib\Tapable.js:138:11)
at ExtractTextPlugin.<anonymous> (C:\Work\Platform\Web\Web.App\node_modules\extract-text-webpack-plugin\index.js:316:4)
at Compilation.applyPluginsAsyncSeries (C:\Work\Platform\Web\Web.App\node_modules\webpack\node_modules\tapable\lib\Tapable.js:142:13)
at sealPart2 (C:\Work\Platform\Web\Web.App\node_modules\webpack\lib\Compilation.js:597:9)
at next (C:\Work\Platform\Web\Web.App\node_modules\webpack\node_modules\tapable\lib\Tapable.js:138:11)
at ExtractTextPlugin.<anonymous> (C:\Work\Platform\Web\Web.App\node_modules\extract-text-webpack-plugin\index.js:292:5)
at C:\Work\Platform\Web\Web.App\node_modules\extract-text-webpack-plugin\node_modules\async\lib\async.js:52:16
at Object.async.forEachOf.async.eachOf (C:\Work\Platform\Web\Web.App\node_modules\extract-text-webpack-plugin\node_modules\async\lib\async.js:236:30)
at Object.async.forEach.async.each (C:\Work\Platform\Web\Web.App\node_modules\extract-text-webpack-plugin\node_modules\async\lib\async.js:209:22)
at ExtractTextPlugin.<anonymous> (C:\Work\Platform\Web\Web.App\node_modules\extract-text-webpack-plugin\index.js:244:10)
at Compilation.applyPluginsAsyncSeries (C:\Work\Platform\Web\Web.App\node_modules\webpack\node_modules\tapable\lib\Tapable.js:142:13)
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 17
- Comments: 33 (5 by maintainers)
Commits related to this issue
- Fix production build (`yarn build` There is a problem with sourcemaps generation on a production build (`yarn build`). The problem is described at the below link, as the current fix is to, change the... — committed to jordan-enev/react-redux-starter-kit by jordan-enev 7 years ago
- Fix production build (`yarn build`) There is a problem with sourcemaps generation on a production build (`yarn build`). The problem is described at the below link, as the current fix is to, change th... — committed to jordan-enev/react-redux-starter-kit by jordan-enev 7 years ago
Google brought me here after searching for a solution for sass/libsass#2312 which is sadly locked so I can’t comment there but maybe this will help someone else:
Before:
.parent { &:hover { color: red; } }
After:
.parent { @at-root #{&}:hover { color: red; } }
Temp fix:
At least we can see the original filename of CSS styles…
If the problem is related to sass, it is probably due to “compressed” outputStyle. I figured it out just change compressed to “compact”.
Here is what I just figured out as a workaround. The location where I had the error with
column: -1
looked like this:The error appeared on the line with
&__col {
which is intended by 2 spaces. Now simply by changing the indentation to 4 spaces fixes the error:Confirmed, it is related to https://github.com/sass/libsass/issues/2312, need fix in
node-sass
I’m having the same issue. If anyone’s interested I have a simpler case reproduced in this repo
One possible workaround is to use
outputStyle: 'compact'
instead ofcompressed
Hi @jhnns in my case the error seems to be
extract-text-webpack-plugin
in conjunction with theminimize
setting fromLoaderOptionsPlugin
see my example repo: https://github.com/maggo/sass-loader-sourcemaps-bugOk, part of related webpack config is:
I’m have just noticed that webpack without
-p
flag compiles styles nicely. This flag launch webpack’s Uglify plugin, as all known. And defineprocess.env.NODE_ENV="production"
. But I by hand set this variable and remove flag-p
and this says the problem is in UglifyJS but I dont know how it related to SCSS… and source mapsStacktrace of error is repeated locally and on Heroku:
@jhnns It’s pretty common. I’ve checked and I have error due to Foundation CSS mixins - they also have
&
in_mixins.scss
- https://github.com/zurb/foundation-sites/blob/develop/scss/util/_mixins.scss.@jcapozzi that’s the only solution that fixed my issue!
Many many many thanks!
Now I’m going to submit a PR to material-components-web
In my case value of column number is equal to length of mixin name. I use expanded outputStyle
And that mixin:
May be it occasion)) But logically, what we do with sass placeholder? Replace! even with mixin name, isnt it)) Also name includes hyphen (negative, minus), Foundation seems to be loving hyphens in names))
It appears this may be related to https://github.com/sass/libsass/issues/2312
+1 Just ran into the same problem: with webpack 2 due to file foundation-si tes/scss/components/_button.scss from bower install (v.6.2.4):
Invalid mapping: {"generated":{"line":2828,"column":2},"source":"webpack:///bower_components/foundation-si tes/scss/components/_button.scss","original":{"line":155,"column":-10},"name":null}
Only “compressed” output triggered it, “compact” & “verbose” are working.
@albertogasparin awesome! This is a good starting point to locate the error. Unfortunately, I don’t have time for that now, but I would be glad if someone of you could tackle it.
Crazy, I’ve never seen mixins and
&
used together: