一、单出口形式
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
生成两个打包文件
Webpack 4 ?学习03(配置入口和出口的进阶使用)
原文地址:https://www.cnblogs.com/hunterxing/p/10425287.html