Comments (16)
This issue could be solved on the level of the compression-webpack-plugin - who is maintaining this plugin right now?
from compression-webpack-plugin.
If it helps, I had the same issue and created a plugin that does this.
https://github.com/TomDeBacker/html-compression-webpack-plugin
Edit: Seems like this is now going to be implemented in compression-webpack-plugin. Deleted previously mentioned repository.
from compression-webpack-plugin.
@michael-ciniawsky Sorry, didn't see the notification. Yeah so my webpack config basically looks like this:
const path = require('path');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const CompressionPlugin = require("compression-webpack-plugin");
module.exports = {
entry: './src/client/index.jsx',
output: {
path: path.join(__dirname, 'dist/'),
filename: '[name].[chunkhash].js',
},
module: {
rules: [
{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
loader: 'babel-loader',
},
{
test: /\.svg$/,
exclude: /node_modules/,
loader: 'react-svg-inline-loader',
},
],
},
plugins: [
new HtmlWebpackPlugin({
template: 'src/client/index.html',
}),
new CopyWebpackPlugin([
{
from: 'src/client/assets/',
to: 'assets/',
}
]),
new webpack.optimize.CommonsChunkPlugin({
name: 'vendor',
minChunks: function(module) {
return module.context && module.context.indexOf("node_modules") !== -1;
},
}),
new webpack.optimize.CommonsChunkPlugin({
name: 'manifest',
minChunks: Infinity
}),
new CompressionPlugin({
asset: "[path].gz[query]",
algorithm: "gzip",
test: /\.js$/,
threshold: 10240,
minRatio: 0.8
})
],
};
This results in a vendor.[hash].js.gz and a main.[hash].js.gz, but only a manifest.[hash].js and no manifest.[hash].js.gz.
from compression-webpack-plugin.
@michael-ciniawsky if I understand correctly, this would also be solved by #45. It's the same problem.
from compression-webpack-plugin.
worth checking if changing minThreshold
to a lower value will solve this, and ensure test
includes html, e.g.,:
test: /\.js$|\.html$/,
minRatio: 0,
from compression-webpack-plugin.
hmm actually I am getting this problem too now - intermittently.
from compression-webpack-plugin.
is this a plugin ordering issue? Is there a race between the HTML plugin and the compression plugin?
from compression-webpack-plugin.
Ran into a similar problem here: markdalgleish/static-site-generator-webpack-plugin#44. There's also a related discussion going on here: jantimon/html-webpack-plugin#142.
from compression-webpack-plugin.
@jantimon Can you explain how compression-webpack-plugin could solve the issue ?
from compression-webpack-plugin.
@michael-ciniawsky there is an event fired by the html-webpack-plugin which could be used
from compression-webpack-plugin.
@jantimon Mind to give 'this event' a name 😛 , in case #45 isn't resolving the problem?
from compression-webpack-plugin.
I'm not exactly sure, but I have an issue that's maybe caused by the same root.
In my app I use CommonChunksPlugin to generate various bundle files including a manifest file like mentioned in the docs.
For the bundle files the compression works just fine. But the manifest file isn't compressed. Might that be the same root cause?
from compression-webpack-plugin.
@r3dDoX Please provide more info on this + show some code 😛
from compression-webpack-plugin.
As just @r3dDoX comments, the same situation happened to me while I was setting up my bundling configuration.
yarn build v0.24.6
$ webpack --config webpack-production.config.js --colors
Hash: ce188de31b921a80fb52
Version: webpack 3.0.0
Assets Size Chunks Chunk Names
manifest.json 81 bytes [emitted]
runtime.ce188de31b921a80fb52.js 8.41 kB runtime [emitted] runtime
vendor.66486fe933c2e8c9d06e.js 2.26 MB vendor [emitted] [big] vendor
main.79885a5e2710a6f17094.js.gz 1.03 MB [emitted] [big]
vendor.66486fe933c2e8c9d06e.js.gz 534 kB [emitted] [big]
main.79885a5e2710a6f17094.js 2.53 MB main [emitted] [big] main
index.html 1.93 kB [emitted]
As can be seen in the extract of my bundle output, only main and vendor files got a gzipped version through compression-webpack-plugin.
Is there a way to tell compression-webpack-plugin to also create this file, or is it not relevant enough?
In that case, I'll have to make some exceptions in my server application just for this file to be served without gzip encoding though.
from compression-webpack-plugin.
@NeaSTDL That's exactly the workaround that I've been using since then...
from compression-webpack-plugin.
from compression-webpack-plugin.
Related Issues (20)
- Getting error TS1005: '?' expected HOT 2
- Always 404, I don't know why, HOT 2
- gzipped css not updated in html file HOT 19
- compress images not work HOT 2
- TypeError: Cannot read properties of undefined (reading 'tapPromise') HOT 1
- Allow usage of 6.x version without md4 HOT 4
- ERROR in Conflict: Multiple assets emit different content to the same filename css/.gz HOT 1
- Restoring failed for CompressionWebpackPlugin; HookWebpackError: this._obj.updateHash is not a function HOT 5
- Some of the files ignored during build compression HOT 10
- How to do this compression from express? HOT 1
- How to use deleteOriginalAssets is true ? HOT 2
- Compressed build now working on browser HOT 6
- Version 6 (for Webpack 4) does not work on Node 18+ HOT 10
- Let users exclude files or folder from deleting original assets. HOT 1
- Compression-webpack-plugin running before HtmlCriticalWebpackPlugin completes. HOT 2
- Ability to exclude files from deletion after zipping. HOT 1
- Type definition `BasePluginOptions` property `test` should use `Rules`, not `Rule`
- compression-webpack-plugin .woff compression is not supported HOT 3
- Bug: `deleteOriginalAssets: true` removes the `.js.LICENSE.txt` files HOT 3
- Bug: `deleteOrigianlAssets: true` breaks the build badly... HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from compression-webpack-plugin.