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

2.0.0-rc.0 not removing css from bundles #366

Closed
phun-ky opened this issue Jan 27, 2017 · 31 comments
Closed

2.0.0-rc.0 not removing css from bundles #366

phun-ky opened this issue Jan 27, 2017 · 31 comments
Milestone

Comments

@phun-ky
Copy link

phun-ky commented Jan 27, 2017

with this config: https://gist.github.com/phun-ky/34744023578f6f000f0de427f11d3800

I am getting bundles with loads of duplicate css in them, like this screenshot:
screenshot from 2017-01-27 14-45-06

I get the correct css files produced, but the styles are still in the bundles

@bebraw bebraw added this to the Webpack 2 release milestone Jan 27, 2017
@bebraw
Copy link
Contributor

bebraw commented Jan 27, 2017

Can you see the same in earlier betas? Any chance for a little project to run?

@bebraw
Copy link
Contributor

bebraw commented Jan 28, 2017

Can you try use: extractTextPlugin.extract? Only the new style is supported now.

@bebraw
Copy link
Contributor

bebraw commented Jan 31, 2017

The old style ( loader: extractTextPlugin.extract) should work too as webpack core supports the legacy format (tried it out). I would need a standalone project to do anything about this issue. This is blocking the release at the moment.

@bebraw
Copy link
Contributor

bebraw commented Feb 4, 2017

@phun-ky Can you set up a standalone example? This is one of the final issues blocking a release.

@phun-ky
Copy link
Author

phun-ky commented Feb 6, 2017 via email

@csonlai
Copy link

csonlai commented Feb 6, 2017

I met the same problem when using webpack2

@bebraw
Copy link
Contributor

bebraw commented Feb 6, 2017

@csonlai I'm still waiting for an example. No way to fix unless someone provides one.

@phun-ky
Copy link
Author

phun-ky commented Feb 6, 2017

https://github.com/phun-ky/webpack-2-extract-text-plugin-example

here it is. It occured to me, that if this is run with webpack -p, no css is in the /assets/app.js file, but with webpack, I get the css in the file.

I will have to research a bit more, because I reported this issue with webpack run programatically, not via cli, with process.NODE_ENV=production

@bebraw
Copy link
Contributor

bebraw commented Feb 7, 2017

@phun-ky I get /assets/app.css with and without -p. It's the same output. Why would you expect to see CSS in /assets/app.js?

@bebraw
Copy link
Contributor

bebraw commented Feb 7, 2017

Anyway, I can't repro the behavior (probably missing some step you did).

It would be good if someone else could it give a go.

@phun-ky
Copy link
Author

phun-ky commented Feb 15, 2017

@bebraw I don't expect to see CSS in /assets/app.js or any of my bundles, that's the point

@bebraw
Copy link
Contributor

bebraw commented Feb 15, 2017

@phun-ky I did not see that behavior myself.

@hulkish
Copy link

hulkish commented Feb 16, 2017

I'm seeing this issue

@bebraw
Copy link
Contributor

bebraw commented Feb 16, 2017

@hulkish Was that against the example above? Can you provide some information on your environment?

@hulkish
Copy link

hulkish commented Feb 17, 2017

@bebraw I'm having issues reproducing this again. However, I am still using same version of everything. I will report again if I see it again.

@bebraw bebraw modified the milestones: 2.1 features/fixes, 2.0 final Feb 19, 2017
@hulkish
Copy link

hulkish commented Feb 23, 2017

Yea, I'm definitely still seeing this issue in rc.3. However, I am having difficulty nailing down the cause.

@hulkish
Copy link

hulkish commented Feb 23, 2017

so, ive tried everything in order to get to the bottom of this one. If anyone else can provide some insight that'd be really helpful.

@scottdj92
Copy link
Contributor

@hulkish can you share your repo?

@hulkish
Copy link

hulkish commented Feb 23, 2017

@scottdj92, it seems to occur when trying to use completely webpack 2 syntax of use, instead of loaders, and / or options instead of query

@hulkish
Copy link

hulkish commented Feb 23, 2017

ibe tried several versions of: sass-loader, postcss-loader, css-loader, style-loader & extract-text-webpack-plugin... it didn't affect my result.. but adding webpack 2 syntax def broke it

@scottdj92
Copy link
Contributor

Can you share your repo and webpack config?

@hulkish
Copy link

hulkish commented Feb 23, 2017

i can't due to proprietary reasons.. but i will try to recreate tge issue in a new repo and share here

@hulkish
Copy link

hulkish commented Feb 23, 2017

perhaps my approach is incorrect.. is the following the intended loader syntax for extract-text-webpack-plugin@2.0.0-rc.3?

{
  module: {
    rules: [
      {
        test: /\.scss$/,
        use: ExtractTextPlugin.extract({
          fallback: { loader: 'style-loader',  options: { sourceMap: true } }, 
          use: [
            { loader: 'css-loader',  options: { sourceMap: true }, 
            { loader: 'postcss-loader',  options: { sourceMap: true }, 
            { loader: 'sass-loader',  options: { sourceMap: true },
          ] 
        }) 
      } 
    ] 
  } 
} 

@bebraw
Copy link
Contributor

bebraw commented Feb 23, 2017

@hulkish You are missing a brace after fallback: { loader: 'style-loader', options: { sourceMap: true },. Could that be it?

There really is no way we could help without a small test case to study.

@hulkish
Copy link

hulkish commented Feb 23, 2017

@bebraw no... thats just my fat thumbs because i wrote it on my phone (i give you permission to point and laugh), just wanted to give a quick idea of what im trying to do

@hulkish
Copy link

hulkish commented Feb 23, 2017

@bebraw can you at least confirm that my snippet above is the correct intended usage?

@scottdj92
Copy link
Contributor

It looks right to me, if you follow with what @bebraw mentioned.

@hulkish
Copy link

hulkish commented Feb 27, 2017

I finally determined the cause...can you spot it?

  plugins: [
    new ExtractTextPlugin({
      filename: '[name].[hash].js',
      allChunks: true,
      disable
    })
  ]

This should have been far more obvious on my part, still don't know how I missed it. Anyway - hopefully my headbutting at least benefits someone else... double triple check your webpack config, folks!

@scottdj92
Copy link
Contributor

Please explain what you fixed, for posterity. Afterwards if there's no other issues, I can close this up! 😄

@hulkish
Copy link

hulkish commented Feb 27, 2017

[name].[hash].js => [name].[hash].css...... walk of shame

@scottdj92
Copy link
Contributor

It happens to the best of us.

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

No branches or pull requests

5 participants