1 - 生成一个npm仓库
yarn init -y
2- 安装依赖
yarn add webpack webpack-cli
3 - 新建.gitignore 文件
node_modulesdistyarn.locksrc(main.js)
4 - 构件核心文件 (webpack.config.js)

// webpack.config.jsconst webpack = require("webpack");const path = require("path");const config = {entry:path.resolve(__dirname,'src/main.js'), //入口文件output:{ //出口文件path:path.resolve(__dirname,'dist'),filename:'bundle.js'},mode:'development' //模式}module.exports = config;
5 - 配置package.json文件
6 - 打包
会在dist目录下生成bundle.js文件(自定义的出口文件名)
npm run buildyarn serve
