Giter Site home page Giter Site logo

Comments (10)

mastilver avatar mastilver commented on July 16, 2024

If you look at the code, it's not actually deleting the file, just removing it from the webpack output

https://github.com/webpack-contrib/compression-webpack-plugin/blob/master/index.js#L84-L86

from compression-webpack-plugin.

michael-ciniawsky avatar michael-ciniawsky commented on July 16, 2024

@myknbani @mastilver Tbh, I need to investigate, why this is the current behaviour and if it's simply a bug. Any position upon that, please express them 😛

from compression-webpack-plugin.

mastilver avatar mastilver commented on July 16, 2024

I guess it could be confusing, but to me it doesn't matter as long as it's removed from assets

from compression-webpack-plugin.

milewski avatar milewski commented on July 16, 2024

I guess his build dir might not be cleared before each build and the js left were result of the previous one...

from compression-webpack-plugin.

myknbani avatar myknbani commented on July 16, 2024

@milewski My build dir is cleared. I'll try this without multiple entry points

$ ls -lh public
total 0
$ yarn build:frontend:prod              
yarn build:frontend:prod v0.22.0
$ rm -rfv public/ && NODE_ENV=production webpack --config webpack-prod.config.js --progress 
removed directory 'public/'

... removed output

$ tree public/
public/
├── images
│   └── cpu-logo.png
├── index.html
└── js
    ├── core.9ac02e1601154e1fac43.js
    ├── manifest.5b61900d77f1b5d85f2c.js
    ├── vendor.ef4fc9cace66a6feb492.js
    └── vendor.ef4fc9cace66a6feb492.js.gz

2 directories, 6 files
$ 

from compression-webpack-plugin.

myknbani avatar myknbani commented on July 16, 2024

Still no luck, I tried removing plugins except Uglify and Compression... with only 1 entry point.
Original asset still there.

public/
├── images
│   └── cpu-logo.png
└── js
    ├── main.374023ff72b5b0e88167.js
    └── main.374023ff72b5b0e88167.js.gz

from compression-webpack-plugin.

michael-ciniawsky avatar michael-ciniawsky commented on July 16, 2024

@myknbani Yep currently this is the expected behaviour according to the code, but the question is why (e.g as fallback) or because the code is incorrect and it can be removed?

from compression-webpack-plugin.

myknbani avatar myknbani commented on July 16, 2024

Sorry, I'm not really familiar with Webpack internals. But I saw this on SO, one guy made a SupressChunkPlugin, and delete was also used.

SuppressEntryChunksPlugin.prototype.apply = function(compiler) {
  var options = this.options;

  // just before webpack is about to emit the chunks,
  // strip out primary file assets (but not additional assets)
  // for entry chunks we've been asked to suppress
  compiler.plugin('emit', function(compilation, callback) {
    compilation.chunks.forEach(function(chunk) {
      if (options.skip.indexOf(chunk.name) >= 0) {
        chunk.files.forEach(function(file) {
          delete compilation.assets[file];
        });
      }
    });
    callback();
  });
};

from compression-webpack-plugin.

myknbani avatar myknbani commented on July 16, 2024

Ugh! I was about to experiment with doing some console.logs inside node_modules, and guess what? I have an old version. I treated the Gthub readme as the official docs.

This is a recent addition and not yet released on NPM! I can see that deleteOriginalAssets is not documented on NPM.

It works with the github version, so sorry for the trouble.

└── js
    ├── core.9ac02e1601154e1fac43.js
    ├── manifest.5b61900d77f1b5d85f2c.js
    └── vendor.ef4fc9cace66a6feb492.js.gz

from compression-webpack-plugin.

joshwiens avatar joshwiens commented on July 16, 2024

@myknbani - I'll have this out on NPM shortly.

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.