404 status code when using option { output.filename: '[name].[contenthash].js' } in webpack.config.js #13824
OptimistLabyrinth
started this conversation in
General
Replies: 1 comment 14 replies
-
|
Do not ignore this |
Beta Was this translation helpful? Give feedback.
14 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Bug report
What is the current behavior?
I apologize in advance that I'm not that good at English.
While I was following the webpack docs guide(https://webpack.js.org/guides/caching/),
I came across an issue.
I'm not sure if this is really an issue or not, but I think it could be problematic.
I tried 3 cases to figure out when the issue occurs and when it doesn't
I used webpack-dev-server to host my webpack bundled app.
package.json file
{ "name": "webpack-any", "version": "1.0.0", "description": "", "private": "true", "scripts": { "start": "npm run build && webpack server --config webpack.prod.js", "build": "webpack --config webpack.prod.js", "dev": "npm run devBuild && webpack server --config webpack.config.js", "devBuild" : "webpack --config webpack.config.js", "clean": "rimraf ./prod/*", "devClean": "rimraf ./dist/*" }, "keywords": [], "author": "", "license": "ISC", "dependencies": { "lodash": "^4.17.21" }, "devDependencies": { "@babel/core": "^7.14.6", "@babel/preset-env": "^7.14.7", "babel-loader": "^8.2.2", "css-loader": "^6.1.0", "csv-loader": "^3.0.3", "html-loader": "^2.1.2", "html-webpack-plugin": "^5.3.2", "rimraf": "^3.0.2", "style-loader": "^3.1.0", "webpack": "^5.45.1", "webpack-cli": "^4.7.2", "webpack-dev-server": "^3.11.2", "webpack-manifest-plugin": "^3.1.1" } }1. Setting output.filename = '[name].bundle.js' + output.publicPath = '/dist/
OK
2. Setting output.filename = '[name].[contenthash].js' + output.publicPath = '/dist/
404 Error Response
3. Setting output.filename = '[name].[contenthash].js' + output.publicPath = 'auto'
OK
If the current behavior is a bug, please provide the steps to reproduce.
What is the expected behavior?
So, I realized
when I use webpack caching machenism such as output.filename = [contenthash].js, I cannot use output.publicPath option.
This happens both in 'development' mode and 'production' mode.
Exprected behavior is
even though the webpack users set output.filename with [contenthash],
webpack output must be adjusted according to the output.publicPath value.
Other relevant information:
webpack version: v5.45.1
Node.js version: v14.15.0
Operating System: ubuntu-20.04-LTS
Additional tools:
Beta Was this translation helpful? Give feedback.
All reactions