You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
Reacted by Xiaohan Zhang, Danny Coates, Marcin Pycio, Jessica Franco, Gelmir, Nelson Chen, Geoffrey Dhuyvetters, crbranch, khronic, Andrea Pinazzi and 96 more
Reacted by Benjamin Favre, Juan Delgadillo, Denis, irudoy, Jim Blue and Miguel Ángel Durán
Please avoid adding +1 comments, they only add confusion to the issue. Instead, add a reaction to the original comment
Reacted by Denis Bendrikov, Juan Manuel Verges, Filipe Silva, Alexis, Arnaud Fabre, Igor Hart, Danny Dombrowski, Shubham Kanodia, Kirsten Kluge, Timothy Lombrana and 33 more
Reacted by Victor Saa
Reacted by Simon Knox, khronic, Jessica Franco, JamesAtEndsleigh, Alexis, Danny Dombrowski, Timothy Lombrana, Ali Torki, Dima Vakatsiienko, PatrickNausha and 4 more
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.
Activity
miantiao-me commentedon Mar 16, 2016
+1
oltsa commentedon May 25, 2016
+1
ComboStyle commentedon May 25, 2016
+1
stefanfrede commentedon Jun 8, 2016
+1
OlegLustenko commentedon Aug 5, 2016
+1
gbhasha commentedon Aug 8, 2016
+1
lancebiu commentedon Sep 3, 2016
+1
shehi commentedon Sep 24, 2016
+1
khronic commentedon Sep 27, 2016
+1
liangsu1210 commentedon Oct 2, 2016
+1
Gpx commentedon Oct 3, 2016
Please avoid adding +1 comments, they only add confusion to the issue. Instead, add a reaction to the original comment
rewmike commentedon Oct 11, 2016
Does anyone have a workaround for this?
Jessidhia commentedon Oct 11, 2016
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.Velenir commentedon Nov 16, 2016
As a workaround you could use
exludeJSChunks: ["css-only chunk"]with html-webpack-template-pug/shameless self-promotion
jkomusin commentedon Apr 11, 2017
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.
kenberkeley commentedon Jul 4, 2017
Solution: https://github.com/jamesjieye/html-webpack-exclude-assets-plugin
heyflo commentedon Sep 19, 2018
Any update on this ? Still having useless
*.jsfiles being generated when having a CSS-Only entry. Thanks for your time 👍xwenliang commentedon Oct 16, 2018
come from webpack/mini-css-extract-plugin#279, any idea here?
Jorenm commentedon Jan 11, 2019
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.
jimblue commentedon Jun 9, 2019
There is so many people having this problem... Is there any update about a fix... This issue is already 3 years old! 😞
stephan-v commentedon Jul 4, 2019
Hahaha don't get your hopes up.
alexander-akait commentedon Oct 6, 2020
Let's close in favor #7300, because it is the same problem, and it fixed in master