安装
mkdir webpack-demo && cd webpack-demo npm init -y npm install webpack webpack-cli --save-dev
快速入门
项目下新建src/index.js webpack.config.js
module.exports = { mode:'development' }
在dist目录下新建index.html页面
运行
npx webpack
Entry
用法 entry:string|Array(string)
Output
用法:
filename:用于文件名的输出
path:目标输出目录,绝对路径
const { resolve } = require('path') module.exports = { entry: './src/index.js', output: { filename: 'app.bundler.js', path: resolve(__dirname, 'dist') }, mode: 'development' }