jantimon / jantimon/html-webpack-plugin
Can't get assets by entry point chunk name in v4
- Dominant language
- JavaScript
- Stars
- 10.7k
- Forks
- 1.3k
- Avg merge
- 1m
- Merged PRs (30d)
- 1
Description
Congrats on the new major version guys.
## Expected behaviour
In v3, it was possible to obtain chunk assets by accessing `htmlWebpackPlugin.files.chunks[entryName].entry` from the template.
## Current behaviour
According to https://github.com/jantimon/html-webpack-plugin/blob/master/CHANGELOG.md#breaking-changes there's a breaking change affecting such feature:
> The chunks property was removed and the js and css property was converted from a string into an object `{ entryName: string, path: string}`
According to that, one would expect `js` and `css` properties in `htmlWebpackPlugin.files` to contain the mentioned object but I still get the same array of strings as in v3:
```js
{
...,
"files": {
"publicPath": "",
"js": [
"scripts/main.js",
"scripts/service-worker.js",
"scripts/ping-worker.js"
],
"css": [
"styles/main.css"
]
},
...
}
```
## Environment
Tell us which operating system you are using, as well as which versions of Node.js, npm, webpack, and html-webpack-plugin. Run the following to get it quickly:
~/projects/lag (dependabot/npm_and_yarn/html-webpack-plugin-4.0.1, Node v12.11.1)
❯ node -e "var os=require('os');console.log('Node.js ' + process.version + '\n' + os.platform() + ' ' + os.release())"
npm --version
npm ls webpack
npm ls html-webpack-plugin
Node.js v12.11.1
darwin 19.3.0~/projects/lag (dependabot/npm_and_yarn/html-webpack-plugin-4.0.1, Node v12.11.1)
❯ npm --version
npm ls webpack
npm ls html-webpack-plugin
6.13.7~/projects/lag (dependabot/npm_and_yarn/html-webpack-plugin-4.0.1, Node v12.11.1)
❯ npm ls webpack
npm ls html-webpack-plugin
lag@0.0.0 /Users/frosas/projects/lag
└── webpack@4.42.0~/projects/lag (dependabot/npm_and_yarn/html-webpack-plugin-4.0.1, Node v12.11.1)
❯ npm ls html-webpack-plugin
lag@0.0.0 /Users/frosas/projects/lag
└── html-webpack-plugin@4.0.1
### Config
Copy the minimal `webpack.config.js` to produce this issue:
https://github.com/frosas/lag/blob/f82961175485b1540cefc7f48bc251dad83df10b/webpack.config.js#L55-L71
Copy your template file if it is part of this issue:
https://github.com/frosas/lag/blob/f82961175485b1540cefc7f48bc251dad83df10b/html/index.ejs
## Additional context
I couldn't find any reference to `entryName` in the plugin code that suggested the new behavior was actually implemented.
Also, `htmlWebpackPlugin.files` section in https://github.com/jantimon/html-webpack-plugin/blob/master/README.md seems outdated now.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with webpack.config.js lines 55-71 and html/index.ejs, then inspect the plugin code for the files object and entryName handling. Reproduce the issue with the linked configuration and compare the output with the v4 changelog and README. Done means entry-point asset lookup behaves as documented, with the README matching the implementation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, webpack
- Domain
- build-system, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100