Giter Site home page Giter Site logo

Comments (8)

nerdmax avatar nerdmax commented on August 15, 2024 8

Just in case some one else find this issue later.

If you are using html-webpack-plugin along side compression-webpack-plugin and you want the html-webpack-plugin to reference the .gz file automatically.

You can try this plugin: html-webpack-change-assets-extension-plugin.

Eg:

plugins: [
  new HtmlWebpackPlugin({
    jsExtension: ".gz"
  }),
  new CompressionPlugin(), // compression plugin will generate the xxx.js.gz file
  new HtmlWebpackChangeAssetsExtensionPlugin()
];

from compression-webpack-plugin.

o-alexandrov avatar o-alexandrov commented on August 15, 2024 1

@akashbiz
You need to set an appropriate header, metadata, for the objects that are gzip compressed, either using the CLI or manually adjusting each object in the web console. Example using CLI:
$ aws s3 sync . s3://bucketName --content-encoding gzip --metadata-directive REPLACE

Btw, you don't need to have both .gz and non-gzipped objects at the same time. AWS S3 uncompresses the objects by itself before responding to the request, if the client's browser doesn't support GZIP. It's also explained in the AWS S3 docs.

from compression-webpack-plugin.

michael-ciniawsky avatar michael-ciniawsky commented on August 15, 2024

If you use html-webpack-plugin, it's a bug/known issue (#71), otherwise compression-webpack-plugin doesn't alter anything by itself here and you need to do it manually

from compression-webpack-plugin.

akashbiz avatar akashbiz commented on August 15, 2024

Yes, I have gone through that issue, but even after changing in index.html manually, in browser its loading entire content within gz file.
My main.bundle.js was 1.1 MB initially without use of compression plugin, after using compression it became 286KB and saved on my local. When I deploy this build on aws s3, it shows 1.1MB transferred for this gzip file in browser dev tools. Also, its not showing the content-encoding as gzip.

Any idea what am I doing wrong?

from compression-webpack-plugin.

akashbiz avatar akashbiz commented on August 15, 2024

Also, If I update .gz extension manually to bundle files still in browser its not showing content-encoding: gzip, Content-Length is also not visible. So is there any other setting required to add these content-encoding as gzip so that browser can download only 286KB and unzip them in browser?

from compression-webpack-plugin.

michael-ciniawsky avatar michael-ciniawsky commented on August 15, 2024

This needs to be configured in your 'webserver' config separately (send with the correct content-encoding header). No idea how to enable it for AWS sry :)

from compression-webpack-plugin.

michael-ciniawsky avatar michael-ciniawsky commented on August 15, 2024

@OlzhasAlexandrov Thx 👍

from compression-webpack-plugin.

rcklmk avatar rcklmk commented on August 15, 2024

@o-alexandrov
Hi, I'm glad that I found your comment, it helped me solve the problem of serving gzipped static assets directly from S3 (especially webpack chunks).

AWS S3 uncompresses the objects by itself before responding to the request, if the client's browser doesn't support GZIP.

With regards to on-the-fly gzip decompression, I was wondering if you could provide any reference to the page that documents this behavior or some way to test it - I tried googling, but the ones I found were talking about CloudFront's automatic compression feature instead. Thanks

from compression-webpack-plugin.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.