webpack.config.js
const path = require('path');module.exports = { //单出口形式 entry:['./public/index.js','./public/index2.js'],//有多个文件 output:{ path:path.resolve(__dirname,'build'), filename:'bundle.js' }}
运行npm run dev
生成唯一的打包文件
bundle.js
? webpack.config.js
const path = require('path');module.exports = { //多出口形式 entry:{ entryOne:'./public/entryOne/index.js', entryTwo:'./public/entryTwo/index.js', }, output:{ path:path.resolve(__dirname,'build'), filename:'[name].js' }}
?
文件结构
运行npm run dev
生成两个打包文件