Skip to content

Eliminate empty chunks? #1967

Closed
Closed

Description

@bebraw

Assuming you have an entry pointing at just CSS files and use ExtractTextPlugin to push those to a file of its own, webpack will still generate a file like this for the chunk:

webpackJsonp([1,3],[function(n,c){}]);

This does literally nothing. But unfortunately tooling like HtmlWebpackPlugin will still generate a script tag for it. It might be sensible to detect noop cases like this and not to emit the JS files at all in these kind of cases.

Activity

  1. miantiao-me commented on Mar 16, 2016

    @miantiao-me

    +1

  2. oltsa commented on May 25, 2016

    @oltsa

    +1

  3. ComboStyle commented on May 25, 2016

    @ComboStyle

    +1

  4. stefanfrede commented on Jun 8, 2016

    @stefanfrede

    +1

  5. OlegLustenko commented on Aug 5, 2016

    @OlegLustenko

    +1

  6. gbhasha commented on Aug 8, 2016

    @gbhasha

    +1

  7. lancebiu commented on Sep 3, 2016

    @lancebiu

    +1

  8. shehi commented on Sep 24, 2016

    @shehi

    +1

  9. khronic commented on Sep 27, 2016

    @khronic

    +1

  10. liangsu1210 commented on Oct 2, 2016

    @liangsu1210

    +1

  11. Gpx commented on Oct 3, 2016

    @Gpx

    Please avoid adding +1 comments, they only add confusion to the issue. Instead, add a reaction to the original comment

  12. rewmike commented on Oct 11, 2016

    @rewmike

    Does anyone have a workaround for this?

  13. Jessidhia commented on Oct 11, 2016

    @Jessidhia

    There is a webpack.optimize.RemoveEmptyChunksPlugin, but I'm not sure it would deal with cases like the snippet in the OP. The code there does have a module in the chunk; it's the module that's empty, not the chunk.

  14. Velenir commented on Nov 16, 2016

    @Velenir

    As a workaround you could use exludeJSChunks: ["css-only chunk"] with html-webpack-template-pug

    /shameless self-promotion

  15. jkomusin commented on Apr 11, 2017

    @jkomusin

    I recently used a plugin with a hook for the 'done' event to remove files for chunks that I knew in advance were going to be empty. Not a great workaround, but it may work for some. https://www.npmjs.com/package/on-build-webpack is an example, as you can see from the source writing your own such plugin is trivial.

  16. kenberkeley commented on Jul 4, 2017

    @kenberkeley
  17. heyflo commented on Sep 19, 2018

    @heyflo

    Any update on this ? Still having useless *.js files being generated when having a CSS-Only entry. Thanks for your time 👍

  18. xwenliang commented on Oct 16, 2018

    @xwenliang

    come from webpack/mini-css-extract-plugin#279, any idea here?

  19. Jorenm commented on Jan 11, 2019

    @Jorenm

    I made a fork of disable-output-webpack-plugin here https://github.com/Jorenm/disable-output-webpack-plugin/tree/options which lets you choose which files to block. I was able to nuke any JS files generated by my stylus compilation.

  20. jimblue commented on Jun 9, 2019

    @jimblue

    There is so many people having this problem... Is there any update about a fix... This issue is already 3 years old! 😞

  21. stephan-v commented on Jul 4, 2019

    @stephan-v

    Hahaha don't get your hopes up.

  22. alexander-akait commented on Oct 6, 2020

    @alexander-akait
    Member

    Let's close in favor #7300, because it is the same problem, and it fixed in master

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions