webpack5.2的安装与使用
1、首先,创建目录: mkdir webpack-test
2、访问该路径:cd webpack-test
3、初始化操作:npm init -y
4、安装webpack及webpack-cli:npm install webpack webpack-cli --save-dev
5、创建src目录和dist目录:mkdir src;mkdir dist
6、创建webpack.config.js文件并输入内容:
var path = require("path")
module.exports = {
entry: './src/script/main.js',
output: {
path: path.resolve(__dirname, './dist/js'),
filename: 'bundle.js'
}
}
7、配置package.json文件,在scripts中配置:"webpack": "webpack --config webpack.config.js --progress --color",如下图:
8、控制台运行命令:npm run webpack
本人初学者,若有问题请及时留言,谢谢!