Skip to content
This repository has been archived by the owner on May 29, 2019. It is now read-only.

Plugin overwrites source maps generated by other plugins #119

Closed
sebald opened this issue Oct 19, 2015 · 24 comments
Closed

Plugin overwrites source maps generated by other plugins #119

sebald opened this issue Oct 19, 2015 · 24 comments

Comments

@sebald
Copy link

sebald commented Oct 19, 2015

I am using ts-loader and it generates the correct source maps. But when I add ExtractTextPlugin as a plugin somthing goes horribly wrong with the creation of the source maps.

Here is the relevant part of my setup:

module: {
    loaders: [

        // Support for Typescript
        { test: /\.ts$/, loader: 'ts' },

        // Support for Styles (CSS/Sass)
        {
            test:   /\.s(c|a)ss$/,
            loader: ExtractTextPlugin.extract(
                'style',
                `css?sourceMap!sass?sourceMap&includePaths[]=${bourbon.includePaths}`
            )
        }
    ]
},

plugins: [
    new ExtractTextPlugin('style.css', {
        allChunks: true
    })
]

With the ExtraTextPlugin enabled I get links to the TypeScript source like test.scss:7. Which is obviously not really the correct file ;-D If I disable the plugin (via disable: true) everything works fine (as long as I am using the source-map option).

I also removed the sourceMap param from the css and sass loader. But even then the source files are broken. With this setting they link to the compiled JS instead to the TypeScript files.

Did anyone encounter the same problem?

@sebald
Copy link
Author

sebald commented Oct 19, 2015

I check the generated code and there is actually no TypeScript source map anymore. But Chrome seems to find one!?

@plopinou
Copy link

I have the same problem using stylus for css and babel with es6.
When I have a js error, it shows that it's in app.styl:10
When looking at the map file, the whole chunk referencing the javascript is not there anymore.

Everything's fine if I disable the plugin.

@cwmoo740
Copy link

Same issue with babel-loader and ExtractTextPlugin. Enabling extract-text outputs this as the sourcemap:

{"version":3,"sources":[],"names":[],"mappings":"","file":"styles.css","sourceRoot":""}

@lanocturne
Copy link

+1

1 similar comment
@elsigh
Copy link

elsigh commented Jan 5, 2016

+1

@eirikurn
Copy link

eirikurn commented Jan 8, 2016

+1

1 similar comment
@willemstuursma
Copy link

+1

@sokra
Copy link
Member

sokra commented Jan 28, 2016

Could you please create a small repro repo so I can test it?

@elsigh
Copy link

elsigh commented Feb 8, 2016

@paulshen and I just did this and discovered that it was our use of sourceMapFilename which was the culprit. Makes sense that the CSS source map overwrites the JS one when sourceMapFilename doesn't include [file] or something to generate a dynamic output name.

@duncangrist
Copy link

@elsigh - confirmed that was my issue too. Thanks for posting that 👍

@jamesthurley
Copy link

Thanks @elsigh, this fixed it for me as well.. I changed sourceMapFilename: '[name].[chunkhash].map' to sourceMapFilename: '[file].map' and it sorted the problem out.

@aaronwng
Copy link

+1

@chaoyangnz
Copy link

chaoyangnz commented Jun 16, 2016

+1 Thanks @elsigh so smart!

@colthreepv
Copy link

This one is so hard to track down on a big webpack config.
I just made an empty repo to isolate the plugin and I was ready to create an issue :/

It should be big over the README.md

uzi pushed a commit to uzi/node-build that referenced this issue Aug 22, 2016
The ExtractTextPlugin has a bug that breaks
sourcemaps when you don't use [file].

See webpack-contrib/extract-text-webpack-plugin#119
joshwiens pushed a commit to PatrickJS/PatrickJS-starter that referenced this issue Jan 5, 2017
It's correcting to use [file] instead [name] in order to support work together with ExtractTextPlugin souremaps

Inspired by:
webpack-contrib/extract-text-webpack-plugin#119
@bebraw bebraw added this to the 2.1 features/fixes milestone Jan 29, 2017
@tconroy
Copy link

tconroy commented Feb 25, 2017

Thank you so much @jamesthurley && @elsigh ! this was indeed the issue and the shared fix worked perfectly for me. Cheers! 🍻

@scamden
Copy link

scamden commented Mar 30, 2017

omg thank you!!!!!!

@amitava82
Copy link

wasted few hours on this. Thanks @elsigh

@chrisvasz
Copy link

More kudos to @elsigh -- that was our issue too!

@seunlanlege
Copy link

I still have this issue and none of the above solutions work for me

@seunlanlege
Copy link

ok so i fixed it by adding:

...
output: {
    sourceMapFilename: '[file].map'
}
...

now it outputs bundle.js.map and index.css.map

@dvakatsiienko
Copy link

The same behavior with empty css source map:

{"version":3,"sources":[],"names":[],"mappings":"","file":"styles.css","sourceRoot":""}

Happens because of purifycss-webpack plugin, spent about 30 mins demystifying. Hope it helps someone.

@liamse
Copy link

liamse commented Mar 9, 2018

Thanks @dvakatsiienko, I have the same problem and after omitting purifycss-webpack (move to production), problem solved.

@ghost
Copy link

ghost commented Jul 30, 2018

The same behavior with empty css source map:

{"version":3,"sources":[],"names":[],"mappings":"","file":"styles-less.css","sourceRoot":"webpack:///"}

/# sourceMappingURL=styles-less.css.map/

Happens because of angular-router-loader plugin.

@alexander-akait
Copy link
Member

DEPRECATED
Please use: https://github.com/webpack-contrib/mini-css-extract-plugin

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

No branches or pull requests