optimize-css-assets-webpack-plugin icon indicating copy to clipboard operation
optimize-css-assets-webpack-plugin copied to clipboard

Can't change source-maps style (Webpack Devtool settings)

Open jimblue opened this issue 7 years ago • 11 comments

Hi there!

I've notice that output source maps style doesn't respect webpack devtool settings when using this plugin.

While using css nano with post-css loader, source maps style perfectly match webpack configuration.

So I guess this issue is due to your plugin.

Thanks for you help!

Cheers

jimblue avatar Oct 21 '18 00:10 jimblue

I have the same problem.

When i use mini-css-extract-plugin plugin, even if pass sourceMap=true in css-loader, source maps are not output

dxx avatar Oct 22 '18 03:10 dxx

I resolved this problem by pass some options

new OptimizeCSSAssetsPlugin({
  cssProcessorOptions: { 
    map: { inline: false }
  }
})

dxx avatar Oct 22 '18 05:10 dxx

Hi @code-mcx ,

I'm not saying source maps are not output ! (already configured the plugin as you suggest)

The problem is how source map are actually output.

Webpack offer different styles of source maps for production:

  • cheap-source-map
  • cheap-module-source-map
  • source-map
  • hidden-source-map
  • nosources-source-map

But changing this setting doesn't affect source map style when using this plugin!

This is a problem when you want to hide your source code while keeping all advantages of source map on a production server.

jimblue avatar Oct 22 '18 16:10 jimblue

@jimblue I'am sorry about i misunderstand your meaning.

dxx avatar Oct 23 '18 02:10 dxx

I've just faced the same issue! Sourcemaps got removed on minimization until I set the cssProcessorOptions.

However even with a working sourceMap I've got the same problem as @jimblue: My settings for devtool are not considered. I'm using nosources-source-map in production to hide my source code but when I use OptimizeCSSAssetsPlugin the whole sources are included in the map :(

@NMFR are there any plans to fix/improve this?

SassNinja avatar Nov 09 '18 10:11 SassNinja

I've been able now to achieve my nosource-source-map by setting sourcesContent: false in the options. However the sourcemap origin paths are now different:

  • without OptimizeCSSAssetsPlugin it's like webpack:///./node_modules/example/abc.scss
  • with OptimizeCSSAssetsPlugin it's like http://localhost:3030/Users/kfalkowski/myproject/assets/src/scss/app.scss

Still not happy with the result :/ I just want the minimization without touching the sourcemap. So far it seems using cssnano via the postcss-loader is the only way to achieve this.

SassNinja avatar Nov 09 '18 11:11 SassNinja

Hey @NMFR, can we have your input about this issue!! Thanks 😃

jimblue avatar Nov 09 '18 13:11 jimblue

Hi, sorry i don't have much time lately to work on this. I will take a look but i cant promise when. If you can and wish to help fell free to open a PR.

NMFR avatar Nov 20 '18 16:11 NMFR

@NMFR Removing Sourcemaps in Production is pretty much a good feature.

          cssProcessorOptions: { 
            map: false
          },

This works somehow.

abhijithvijayan avatar Jan 07 '19 18:01 abhijithvijayan

+1, would be great for this to respect the devtool setting!

alexturpin avatar Jan 14 '19 16:01 alexturpin

Related to #91 and https://github.com/NMFR/optimize-css-assets-webpack-plugin/issues/53#issuecomment-494830816.

galvarez421 avatar May 22 '19 14:05 galvarez421