Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Enable gzip compression on webpack-dev-server?

How do you enable gzip compression on the webpack-dev-server? It doesn't appear to be on by default.

like image 879
Josh Unger Avatar asked Mar 03 '16 23:03

Josh Unger


People also ask

How do I enable gzip compression on my server?

Gzip on Windows Servers (IIS Manager)Open up IIS Manager. Click on the site you want to enable compression for. Click on Compression (under IIS) Now Enable static compression and you are done!

Does webpack use gzip?

Since static compression involves compressing files ahead of time, webpack settings can be modified to compress assets as part of the build step. CompressionPlugin can be used for this. By default, the plugin compresses the build files using gzip .

How do you check gzip compression is enabled or not?

Double click on the file and select headers. Under 'Response headers' you are looking for the 'Connection-Encoding' field, it will say gzip if it is enabled. NOTE: By default, Deflate is enabled on all of our servers.

How do I compress a webpack?

webpack.config.jsconst CompressionPlugin = require("compression-webpack-plugin"); module. exports = { plugins: [new CompressionPlugin()], }; And run webpack via your preferred method.


1 Answers

1) Insert this line before app.use(require('webpack-dev-middleware')...:

app.use(express.compress());  

2) According to source code there is undocumented option compress:

$ webpack-dev-server ... --compress
like image 161
Bob Sponge Avatar answered Sep 19 '22 12:09

Bob Sponge