安装前先npm初始化
npm init -y
npm i webpack webpack-cli -D
let path = require('path') // 相对路径变绝对路径
module.exports = {
mode: 'production', // 模式 默认 production development
entry: './src/index', // 入口
output: {
filename: 'bundle.[hash:8].js', // hash: 8只显示8位
path: path.resolve(__dirname, 'dist'),
publicPath: 'http://www.mayufo.cn' // // 给所有打包文件引入时加前缀,包括css,js,img,如果只想处理图片可以单独在url-loader配置中加publicPath
}
}