shellscape / webpack-manifest-plugin

webpack plugin for generating asset manifests
MIT License
1.43k stars 186 forks source link

Allow to use function as publicPath #164

Closed nkbt closed 3 years ago

nkbt commented 5 years ago

Webpack has added support to use use function as publicPath quite a while ago

Commit: https://github.com/webpack/webpack/commit/fb4070442a3c0feb115dbb9229ccd0dc1458b30d

At this moment publicPath in webpack-manifest-plugin is assumed to be a string, so when I am using function as webpack.output.publicPath option, I ended up with something like this in my manifest.json:

{
  "bootstrap.js": "url => `/static/${url}`bootstrap.js",
  "main.css": "url => `/static/${url}`main.css"
}

Here is exactly why it is happening:

    var publicPath = this.opts.publicPath != null ? this.opts.publicPath : compilation.options.output.publicPath;

  // ...
  // then further in the code function is implicitly casted to String

    if (publicPath) {
      files = files.map(function(file) {
        file.path = publicPath + file.path;
        //                ^^^^^^^^^^^^^^^ here function publicPath is converted to string
        return file;
      }.bind(this));
    }
towry commented 5 years ago

I assume this will solve the multiple publicPath problem.

shellscape commented 3 years ago

Hey all! I've taken over maintenance of the plugin and am doing some housecleaning. For Issues over a year old without a reproduction, we're going to go the route of closing them first. However, they're not dead! If the issue is still pending and still a problem, please reply with a reproduction and we'll reopen post-haste.

Please provide a reproduction by choosing one of the options below:

  1. Using the REPL.it plugin reproduction template at https://repl.it/@shellscape/manifest-plugin-repro
  2. Provide a minimal repository link (Read https://git.io/fNzHA for instructions). Please use NPM for installing dependencies! These may take more time to triage than the other options.

    ⚠️ ZIP Files are unsafe and maintainers will NOT download them.