想要实现如下多页面、多出口目录的webpack打包,将src的目录结构打包成dist格式的目录,npm里的共用文件打到common里,单个文件夹内的文件还打包在单个文件夹目录下。
研究了好久,发现webpack没有这个多出口配置的个性化方式。有没有大佬接触过这种格式的打包,指点一下webpack能否实现。
├─dist
│ └─pages
│ ├─common
│ │ ├─fonts
│ │ │ mui-8820b.min.ttf
│ │ │
│ │ └─vendors
│ │ ├─css
│ │ │ 0-89b957fd4840f0478171.css
│ │ │
│ │ └─js
│ │ 0-89b957fd4840f0478171.js
│ │
│ ├─mail
│ │ │ mail_detail.html
│ │ │ mail_index.html
│ │ │
│ │ ├─css
│ │ │ mail_detail-89b957fd4840f0478171.css
│ │ │ mail_index-89b957fd4840f0478171.css
│ │ │
│ │ ├─img
│ │ │ img_mail_xx.1.jpg
│ │ │ img_mail_xx.jpg
│ │ │
│ │ └─js
│ │ mail_detail-89b957fd4840f0478171.js
│ │ mail_index-89b957fd4840f0478171.js
│ │
│ └─todo
│ │ todo_detail.html
│ │ todo_index.html
│ │
│ ├─css
│ │ todo_detail-89b957fd4840f0478171.css
│ │ todo_index-89b957fd4840f0478171.css
│ │
│ ├─img
│ │ img_todo_xx.1.jpg
│ │ img_todo_xx.jpg
│ │
│ └─js
│ todo_detail-89b957fd4840f0478171.js
│ todo_index-89b957fd4840f0478171.js
│
└─src
│ └─pages
│ ├─mail
│ │ │ mail_detail.html
│ │ │ mail_index.html
│ │ │
│ │ ├─css
│ │ │ mail_detail.css
│ │ │ mail_index.css
│ │ │
│ │ ├─img
│ │ │ img_mail_xx.1.jpg
│ │ │ img_mail_xx.jpg
│ │ │
│ │ └─js
│ │ mail_detail.js
│ │ mail_index.js
│ │
│ └─todo
│ │ todo_detail.html
│ │ todo_index.html
│ │
│ ├─css
│ │ todo_detail.css
│ │ todo_index.css
│ │
│ ├─img
│ │ img_todo_xx.1.jpg
│ │ img_todo_xx.jpg
│ │
│ └─js
│ todo_detail.js
│ todo_index.js
│
解决了,之前主要是js和css没找到如何单独根据文件夹名称进行判断打包,后来看了文档发现output的fileName可以使用函数判断控制。output-filename