Giter Site home page Giter Site logo

Comments (16)

jantimon avatar jantimon commented on August 15, 2024 2

This issue could be solved on the level of the compression-webpack-plugin - who is maintaining this plugin right now?

from compression-webpack-plugin.

TomDeBacker avatar TomDeBacker commented on August 15, 2024 2

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.

r3dDoX avatar r3dDoX commented on August 15, 2024 2

@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.

ijpiantanida avatar ijpiantanida commented on August 15, 2024 1

@michael-ciniawsky if I understand correctly, this would also be solved by #45. It's the same problem.

from compression-webpack-plugin.

richtier avatar richtier commented on August 15, 2024

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.

richtier avatar richtier commented on August 15, 2024

hmm actually I am getting this problem too now - intermittently.

from compression-webpack-plugin.

graingert avatar graingert commented on August 15, 2024

is this a plugin ordering issue? Is there a race between the HTML plugin and the compression plugin?

from compression-webpack-plugin.

ljfranklin avatar ljfranklin commented on August 15, 2024

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.

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

@jantimon Can you explain how compression-webpack-plugin could solve the issue ?

from compression-webpack-plugin.

jantimon avatar jantimon commented on August 15, 2024

@michael-ciniawsky there is an event fired by the html-webpack-plugin which could be used

from compression-webpack-plugin.

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

@jantimon Mind to give 'this event' a name 😛 , in case #45 isn't resolving the problem?

from compression-webpack-plugin.

r3dDoX avatar r3dDoX commented on August 15, 2024

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.

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

@r3dDoX Please provide more info on this + show some code 😛

from compression-webpack-plugin.

NeaSTDL avatar NeaSTDL commented on August 15, 2024

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.

r3dDoX avatar r3dDoX commented on August 15, 2024

@NeaSTDL That's exactly the workaround that I've been using since then...

from compression-webpack-plugin.

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

#71

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.