1. 起步与安装
mkdir webpack-demo
cd webpack-demo
npm init -y
npm install webpack webpack-cli --save-dev
2. 配置文件
// webpack.config.js
const path = require('path')
module.exports = {
entry: './src/index.js',
output: {
filename: 'bundle.js',
path: path.resolve(__dirname, 'dist')
}
}
自定义配置文件名,webpack.cfg.js
npx webpack --config webpack.cfg.js
3. 打包
npx webpack
npm run bundle
网友评论