The setting of the (output filename option for help in Webpack is not valid)

when I packaged with webpack version 4.0 or later, I found that when I specified filename, in the output option of webpack.config.js, the result was always main.js,. Why? Is there any divine guidance?
the following drawings and code:

//webpack.config.js
var path = require("path")
module.export = {
    entry: path.resolve(__dirname, "./index.js"),
    output: {
        path: path.resolve(__dirname, "./dist"),
        filename: ".js/bundle.[name].[hash].js"
    }
}
//package.json
{
  "name": "webpack-practice-singlepage",
  "version": "1.0.0",
  "description": "this project is for spa practice",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "dev": "webpack --mode=development",
    "build": "webpack --mode=production"
  },
  "author": "Manfray",
  "license": "ISC",
  "devDependencies": {
    "webpack": "^4.5.0",
    "webpack-cli": "^2.0.14"
  }
}

then after I npm run dev, dist dist/main.js

is generated in the project directory.

then why didn"t my filename work?

Mar.02,2021

filename: '.js/bundle.[name].[hash].js'

filename: 'bundle.[name].[hash].js'

means that module.export misspelled
should be module.exports


you need to put webpack.config.js in the root directory of the project, and then, after packing it again, I also encounter this problem, and there will be no problem to release it.

Menu