when i run "npx webpack --config webpack.config.js", it keeps generating "main.js" in the dist folder even if i configured it to be "bundle.js", and the console will show this:
asset main.js 0 bytes [compared for emit] [minimized] (name: main)./src/index.js 1 bytes [built] [code generated]
WARNING in configuration The 'mode' option has not been set, webpack will fallback to 'production' for this value. Set 'mode' option to 'development' or 'production' to enable defaults for each environment. You can also set it to 'none' to disable any default behavior. Learn more: https://webpack.js.org/configuration/mode/
webpack 5.24.4 compiled with 1 warning in 167 ms
my current file structure:
/root
/dist
/src
index.js
/node_modules
package.json
package-lock.json
webpack.config.js
package.json:
{
"name": "mydemo",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"react": "^17.0.1",
"react-dom": "^17.0.1"
},
"devDependencies": {
"webpack": "^5.24.4",
"webpack-cli": "^4.5.0"
}
}
webpack.config.js:
const path = require('path')
module.exports = {
entry: path.resolve(__dirname, 'src', 'index.js'),
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'bundle.js'
}
}
it turns out to be that I am not familiar with vscode, when I edited all of the config files, I did not save, so I guess the builder just took whatever the config was last time and run it.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.