小技巧:为了在编写webpack.config.js配置文件的时候可以有代码 提示,我们可以把这样的一行代码放到导出语句之前
/**
* @type {import('webpack').Configuration}
*/
module.exports = { ... }
module.exports = {
entry: './src/index.js', // 设置入口文件
// 设置打包出口
output: {
filename: 'dist.js',
path: path.join(__dirname, '/dist') // 出口路径要求必须是绝对路径
},
module:{
rules: [
// loader
]
},
plugins: [],
mode: ''
}
npx webpack
webpack.config.js文件,把配置对象中的配置作为webpack的配置执行打包