Commonly used configuration
output: { filename: './js/[name].[hash:8].js', path: Path. resolve(__dirname, 'dist'), /* * filename: If the webpack-dev-server mode is used, chunkhash cannot be used. * * path: the output path must be absolute, dist output file directory * * publicPath: To set hot updates, you must add publicPath * */}.Copy the code
Related parameters:
-
The Output attribute tells WebPack where to export the bundles it creates and how to name the files. The default main output file is./dist/main.js and the default output directory for the other generated files is./dist. You can configure these processes by specifying an output field in the configuration
-
Path: the destination path of all output files. Path is the output path of all webpack files. It must be an absolute path. For example, JS output by OUTPUT, images parsed by URL-loader, and HTML files generated by HtmlWebpackPlugin are all stored in the path-based directory
-
PublicPath: the directory that outputs parsed files. The URL is relative to the HTML page. PublicPath does not affect the path of the generated file. It is mainly used to complete the path of the resources introduced in your page, such as the image introduced in the CSS file