webpack.config.js 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739
  1. const path = require('path');
  2. const HtmlWebpackPlugin = require('html-webpack-plugin');
  3. /*const HtmlWebpackInlineSourcePlugin=require('html-webpack-inline-source-plugin');*/
  4. const CleanWebpackPlugin = require('clean-webpack-plugin') // 清空打包目录的插件
  5. const MiniCssExtractPlugin = require('mini-css-extract-plugin');
  6. const CopyWebpackPlugin = require('copy-webpack-plugin');
  7. const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
  8. const webpack = require('webpack');
  9. // const proxyHost = "http://192.168.2.236:5858";
  10. const proxyHost = "http://192.168.2.241:5858";
  11. // const proxyHost = "http://192.168.3.117:5858";//铁钢
  12. // const proxyHost = "http://192.168.3.113:5858";//王峰
  13. module.exports = {
  14. entry: {
  15. index: path.resolve(__dirname, 'src/js', 'index.js'),
  16. qcScore:path.resolve(__dirname, 'src/js', 'qcScore.js'),
  17. login:path.resolve(__dirname, 'src/js', 'login.js'),
  18. console:path.resolve(__dirname, 'src/js', 'console.js'),
  19. deptConsole:path.resolve(__dirname, 'src/js', 'deptConsole.js'),
  20. moduleManager: path.resolve(__dirname, 'src/js', 'moduleManager.js'),
  21. itemManager: path.resolve(__dirname, 'src/js', 'itemManager.js'),
  22. qcList: path.resolve(__dirname, 'src/js', 'qcList.js'),
  23. qcListDocteam:path.resolve(__dirname, 'src/js', 'qcListDocteam.js'),
  24. qcListDept:path.resolve(__dirname, 'src/js', 'qcListDept.js'),
  25. qcListPerson:path.resolve(__dirname, 'src/js', 'qcListPerson.js'),
  26. userManager: path.resolve(__dirname, 'src/js', 'userManager.js'),
  27. roleManager: path.resolve(__dirname, 'src/js', 'roleManager.js'),
  28. tiaomu: path.resolve(__dirname, 'src/js', 'tiaomu.js'),
  29. mukuai: path.resolve(__dirname, 'src/js', 'mukuai.js'),
  30. abnormal: path.resolve(__dirname, 'src/js', 'abnormal.js'),
  31. partDetail: path.resolve(__dirname, 'src/js', 'partDetail.js'),
  32. dayDetail: path.resolve(__dirname, 'src/js', 'dayDetail.js'),
  33. payDetail: path.resolve(__dirname, 'src/js', 'payDetail.js'),
  34. deptScoreDetail: path.resolve(__dirname, 'src/js', 'deptScoreDetail.js'),
  35. deptScoreDetailControl: path.resolve(__dirname, 'src/js', 'deptScoreDetailControl.js'),
  36. jiaji: path.resolve(__dirname, 'src/js', 'jiaji.js'),
  37. partDetailControl: path.resolve(__dirname, 'src/js', 'partDetailControl.js'),
  38. quexianXQ: path.resolve(__dirname, 'src/js', 'quexianXQ.js'),
  39. quexianDetail: path.resolve(__dirname, 'src/js', 'quexianDetail.js'),
  40. quexianDetailControl: path.resolve(__dirname, 'src/js', 'quexianDetailControl.js'),
  41. quexianDetailHome: path.resolve(__dirname, 'src/js', 'quexianDetailHome.js'),
  42. quexianDetailControlHome: path.resolve(__dirname, 'src/js', 'quexianDetailControlHome.js'),
  43. mukuaiControl: path.resolve(__dirname, 'src/js', 'mukuaiControl.js'),
  44. tiaomuControl: path.resolve(__dirname, 'src/js', 'tiaomuControl.js'),
  45. assertType: path.resolve(__dirname, 'src/js', 'assertType.js'),
  46. assertTypeDetail: path.resolve(__dirname, 'src/js', 'assertTypeDetail.js'),
  47. singleVeto:path.resolve(__dirname, 'src/js', 'singleVeto.js'),
  48. itemDefectDetail:path.resolve(__dirname, 'src/js', 'itemDefectDetail.js'),
  49. keyItemFlawControl:path.resolve(__dirname, 'src/js', 'keyItemFlawControl.js'),
  50. qcListCopy:path.resolve(__dirname, 'src/js', 'qcListCopy.js'),
  51. qcListOutHospital:path.resolve(__dirname, 'src/js', 'qcListOutHospital.js'),
  52. checkControl:path.resolve(__dirname, 'src/js', 'checkControl.js'),
  53. advice:path.resolve(__dirname, 'src/js', 'advice.js'),
  54. uncorrectedCasesStatistics:path.resolve(__dirname, 'src/js', 'uncorrectedCasesStatistics.js'),
  55. uccDetail:path.resolve(__dirname, 'src/js', 'uccDetail.js'),
  56. readmission:path.resolve(__dirname, 'src/js', 'readmission.js'),
  57. vendor: 'lodash'// 多个页面所需的公共库文件,防止重复打包带入
  58. },
  59. output: {
  60. publicPath: '/', //这里要放的是静态资源CDN的地址
  61. path: path.resolve(__dirname, 'dist'),
  62. filename: 'js/[name].js'
  63. },
  64. resolve: {
  65. extensions: [".js", ".css", ".json"],
  66. alias: {} //配置别名可以加快webpack查找模块的速度
  67. },
  68. plugins: [//多入口的html文件用chunks这个参数来区分
  69. new HtmlWebpackPlugin({
  70. title: 'index',
  71. template: path.resolve(__dirname, 'src/html', 'index.html'),
  72. filename: 'index.html',
  73. chunks: ['index', 'vendor', 'common','scrollBar'],
  74. hash: true, //防止缓存
  75. inject: true,
  76. minify: {
  77. removeAttributeQuotes: true, //压缩 去掉引号
  78. removeComments: true, //移除HTML中的注释
  79. collapseWhitespace: true //删除空白符与换行符
  80. }
  81. }),
  82. new HtmlWebpackPlugin({
  83. title: 'console.html',
  84. template: path.resolve(__dirname, 'src/html', 'console.html'),
  85. filename: 'console.html',
  86. chunks: ['console', 'vendor', 'common','scrollBar'],
  87. hash: true, //防止缓存
  88. inject: true,
  89. minify: {
  90. removeAttributeQuotes: true, //压缩 去掉引号
  91. removeComments: true, //移除HTML中的注释
  92. collapseWhitespace: true //删除空白符与换行符
  93. }
  94. }),
  95. new HtmlWebpackPlugin({
  96. title: 'advice.html',
  97. template: path.resolve(__dirname, 'src/html', 'advice.html'),
  98. filename: 'advice.html',
  99. chunks: ['advice', 'vendor', 'common'],
  100. hash: true, //防止缓存
  101. inject: true,
  102. minify: {
  103. removeAttributeQuotes: true, //压缩 去掉引号
  104. removeComments: true, //移除HTML中的注释
  105. collapseWhitespace: true //删除空白符与换行符
  106. }
  107. }),
  108. new HtmlWebpackPlugin({
  109. title: 'tiaomuControl.html',
  110. template: path.resolve(__dirname, 'src/html', 'tiaomuControl.html'),
  111. filename: 'tiaomuControl.html',
  112. chunks: ['tiaomuControl', 'vendor', 'common'],
  113. hash: true, //防止缓存
  114. inject: true,
  115. minify: {
  116. removeAttributeQuotes: true, //压缩 去掉引号
  117. removeComments: true, //移除HTML中的注释
  118. collapseWhitespace: true //删除空白符与换行符
  119. }
  120. }),
  121. new HtmlWebpackPlugin({
  122. title: 'checkControl.html',
  123. template: path.resolve(__dirname, 'src/html', 'checkControl.html'),
  124. filename: 'checkControl.html',
  125. chunks: ['checkControl', 'vendor', 'common'],
  126. hash: true, //防止缓存
  127. inject: true,
  128. minify: {
  129. removeAttributeQuotes: true, //压缩 去掉引号
  130. removeComments: true, //移除HTML中的注释
  131. collapseWhitespace: true //删除空白符与换行符
  132. }
  133. }),
  134. new HtmlWebpackPlugin({
  135. title: 'assertTypeDetail.html',
  136. template: path.resolve(__dirname, 'src/html', 'assertTypeDetail.html'),
  137. filename: 'assertTypeDetail.html',
  138. chunks: ['assertTypeDetail', 'vendor', 'common'],
  139. hash: true, //防止缓存
  140. inject: true,
  141. minify: {
  142. removeAttributeQuotes: true, //压缩 去掉引号
  143. removeComments: true, //移除HTML中的注释
  144. collapseWhitespace: true //删除空白符与换行符
  145. }
  146. }),
  147. new HtmlWebpackPlugin({
  148. title: 'assertType.html',
  149. template: path.resolve(__dirname, 'src/html', 'assertType.html'),
  150. filename: 'assertType.html',
  151. chunks: ['assertType', 'vendor', 'common'],
  152. hash: true, //防止缓存
  153. inject: true,
  154. minify: {
  155. removeAttributeQuotes: true, //压缩 去掉引号
  156. removeComments: true, //移除HTML中的注释
  157. collapseWhitespace: true //删除空白符与换行符
  158. }
  159. }),
  160. new HtmlWebpackPlugin({
  161. title: 'mukuaiControl.html',
  162. template: path.resolve(__dirname, 'src/html', 'mukuaiControl.html'),
  163. filename: 'mukuaiControl.html',
  164. chunks: ['mukuaiControl', 'vendor', 'common'],
  165. hash: true, //防止缓存
  166. inject: true,
  167. minify: {
  168. removeAttributeQuotes: true, //压缩 去掉引号
  169. removeComments: true, //移除HTML中的注释
  170. collapseWhitespace: true //删除空白符与换行符
  171. }
  172. }),
  173. new HtmlWebpackPlugin({
  174. title: 'quexianDetail.html',
  175. template: path.resolve(__dirname, 'src/html', 'quexianDetail.html'),
  176. filename: 'quexianDetail.html',
  177. chunks: ['quexianDetail', 'vendor', 'common'],
  178. hash: true, //防止缓存
  179. inject: true,
  180. minify: {
  181. removeAttributeQuotes: true, //压缩 去掉引号
  182. removeComments: true, //移除HTML中的注释
  183. collapseWhitespace: true //删除空白符与换行符
  184. }
  185. }),
  186. new HtmlWebpackPlugin({
  187. title: 'quexianDetailHome.html',
  188. template: path.resolve(__dirname, 'src/html', 'quexianDetailHome.html'),
  189. filename: 'quexianDetailHome.html',
  190. chunks: ['quexianDetailHome', 'vendor', 'common'],
  191. hash: true, //防止缓存
  192. inject: true,
  193. minify: {
  194. removeAttributeQuotes: true, //压缩 去掉引号
  195. removeComments: true, //移除HTML中的注释
  196. collapseWhitespace: true //删除空白符与换行符
  197. }
  198. }),
  199. new HtmlWebpackPlugin({
  200. title: 'quexianDetailControl.html',
  201. template: path.resolve(__dirname, 'src/html', 'quexianDetailControl.html'),
  202. filename: 'quexianDetailControl.html',
  203. chunks: ['quexianDetailControl', 'vendor', 'common'],
  204. hash: true, //防止缓存
  205. inject: true,
  206. minify: {
  207. removeAttributeQuotes: true, //压缩 去掉引号
  208. removeComments: true, //移除HTML中的注释
  209. collapseWhitespace: true //删除空白符与换行符
  210. }
  211. }),
  212. new HtmlWebpackPlugin({
  213. title: 'quexianDetailControlHome.html',
  214. template: path.resolve(__dirname, 'src/html', 'quexianDetailControlHome.html'),
  215. filename: 'quexianDetailControlHome.html',
  216. chunks: ['quexianDetailControlHome', 'vendor', 'common'],
  217. hash: true, //防止缓存
  218. inject: true,
  219. minify: {
  220. removeAttributeQuotes: true, //压缩 去掉引号
  221. removeComments: true, //移除HTML中的注释
  222. collapseWhitespace: true //删除空白符与换行符
  223. }
  224. }),
  225. new HtmlWebpackPlugin({
  226. title: 'quexianXQ.html',
  227. template: path.resolve(__dirname, 'src/html', 'quexianXQ.html'),
  228. filename: 'quexianXQ.html',
  229. chunks: ['quexianXQ', 'vendor', 'common'],
  230. hash: true, //防止缓存
  231. inject: true,
  232. minify: {
  233. removeAttributeQuotes: true, //压缩 去掉引号
  234. removeComments: true, //移除HTML中的注释
  235. collapseWhitespace: true //删除空白符与换行符
  236. }
  237. }),
  238. new HtmlWebpackPlugin({
  239. title: 'partDetailControl.html',
  240. template: path.resolve(__dirname, 'src/html', 'partDetailControl.html'),
  241. filename: 'partDetailControl.html',
  242. chunks: ['partDetailControl', 'vendor', 'common'],
  243. hash: true, //防止缓存
  244. inject: true,
  245. minify: {
  246. removeAttributeQuotes: true, //压缩 去掉引号
  247. removeComments: true, //移除HTML中的注释
  248. collapseWhitespace: true //删除空白符与换行符
  249. }
  250. }),
  251. new HtmlWebpackPlugin({
  252. title: 'jiaji.html',
  253. template: path.resolve(__dirname, 'src/html', 'jiaji.html'),
  254. filename: 'jiaji.html',
  255. chunks: ['jiaji', 'vendor', 'common'],
  256. hash: true, //防止缓存
  257. inject: true,
  258. minify: {
  259. removeAttributeQuotes: true, //压缩 去掉引号
  260. removeComments: true, //移除HTML中的注释
  261. collapseWhitespace: true //删除空白符与换行符
  262. }
  263. }),
  264. new HtmlWebpackPlugin({
  265. title: 'abnormal.html',
  266. template: path.resolve(__dirname, 'src/html', 'abnormal.html'),
  267. filename: 'abnormal.html',
  268. chunks: ['abnormal', 'vendor', 'common'],
  269. hash: true, //防止缓存
  270. inject: true,
  271. minify: {
  272. removeAttributeQuotes: true, //压缩 去掉引号
  273. removeComments: true, //移除HTML中的注释
  274. collapseWhitespace: true //删除空白符与换行符
  275. }
  276. }),
  277. new HtmlWebpackPlugin({
  278. title: 'deptScoreDetailControl.html',
  279. template: path.resolve(__dirname, 'src/html', 'deptScoreDetailControl.html'),
  280. filename: 'deptScoreDetailControl.html',
  281. chunks: ['deptScoreDetailControl', 'vendor', 'common'],
  282. hash: true, //防止缓存
  283. inject: true,
  284. minify: {
  285. removeAttributeQuotes: true, //压缩 去掉引号
  286. removeComments: true, //移除HTML中的注释
  287. collapseWhitespace: true //删除空白符与换行符
  288. }
  289. }),
  290. new HtmlWebpackPlugin({
  291. title: 'payDetail.html',
  292. template: path.resolve(__dirname, 'src/html', 'payDetail.html'),
  293. filename: 'payDetail.html',
  294. chunks: ['payDetail', 'vendor', 'common'],
  295. hash: true, //防止缓存
  296. inject: true,
  297. minify: {
  298. removeAttributeQuotes: true, //压缩 去掉引号
  299. removeComments: true, //移除HTML中的注释
  300. collapseWhitespace: true //删除空白符与换行符
  301. }
  302. }),
  303. new HtmlWebpackPlugin({
  304. title: 'partDetail.html',
  305. template: path.resolve(__dirname, 'src/html', 'partDetail.html'),
  306. filename: 'partDetail.html',
  307. chunks: ['partDetail', 'vendor', 'common'],
  308. hash: true, //防止缓存
  309. inject: true,
  310. minify: {
  311. removeAttributeQuotes: true, //压缩 去掉引号
  312. removeComments: true, //移除HTML中的注释
  313. collapseWhitespace: true //删除空白符与换行符
  314. }
  315. }),
  316. new HtmlWebpackPlugin({
  317. title: 'dayDetail.html',
  318. template: path.resolve(__dirname, 'src/html', 'dayDetail.html'),
  319. filename: 'dayDetail.html',
  320. chunks: ['dayDetail', 'vendor', 'common'],
  321. hash: true, //防止缓存
  322. inject: true,
  323. minify: {
  324. removeAttributeQuotes: true, //压缩 去掉引号
  325. removeComments: true, //移除HTML中的注释
  326. collapseWhitespace: true //删除空白符与换行符
  327. }
  328. }),
  329. new HtmlWebpackPlugin({
  330. title: 'deptScoreDetail.html',
  331. template: path.resolve(__dirname, 'src/html', 'deptScoreDetail.html'),
  332. filename: 'deptScoreDetail.html',
  333. chunks: ['deptScoreDetail', 'vendor', 'common'],
  334. hash: true, //防止缓存
  335. inject: true,
  336. minify: {
  337. removeAttributeQuotes: true, //压缩 去掉引号
  338. removeComments: true, //移除HTML中的注释
  339. collapseWhitespace: true //删除空白符与换行符
  340. }
  341. }),
  342. new HtmlWebpackPlugin({
  343. title: 'deptConsole.html',
  344. template: path.resolve(__dirname, 'src/html', 'deptConsole.html'),
  345. filename: 'deptConsole.html',
  346. chunks: ['deptConsole', 'vendor', 'common'],
  347. hash: true, //防止缓存
  348. inject: true,
  349. minify: {
  350. removeAttributeQuotes: true, //压缩 去掉引号
  351. removeComments: true, //移除HTML中的注释
  352. collapseWhitespace: true //删除空白符与换行符
  353. }
  354. }),
  355. new HtmlWebpackPlugin({
  356. title: 'itemManager.html',
  357. template: path.resolve(__dirname, 'src/html', 'itemManager.html'),
  358. filename: 'itemManager.html',
  359. chunks: ['itemManager', 'vendor', 'common'],
  360. hash: true, //防止缓存
  361. inject: true,
  362. minify: {
  363. removeAttributeQuotes: true, //压缩 去掉引号
  364. removeComments: true, //移除HTML中的注释
  365. collapseWhitespace: true //删除空白符与换行符
  366. }
  367. }),
  368. new HtmlWebpackPlugin({
  369. title: 'moduleManager.html',
  370. template: path.resolve(__dirname, 'src/html', 'moduleManager.html'),
  371. filename: 'moduleManager.html',
  372. chunks: ['moduleManager', 'vendor', 'common'],
  373. hash: true, //防止缓存
  374. inject: true,
  375. minify: {
  376. removeAttributeQuotes: true, //压缩 去掉引号
  377. removeComments: true, //移除HTML中的注释
  378. collapseWhitespace: true //删除空白符与换行符
  379. }
  380. }),
  381. new HtmlWebpackPlugin({
  382. title: 'tiaomu.html',
  383. template: path.resolve(__dirname, 'src/html', 'tiaomu.html'),
  384. filename: 'tiaomu.html',
  385. chunks: ['tiaomu', 'vendor', 'common'],
  386. hash: true, //防止缓存
  387. inject: true,
  388. minify: {
  389. removeAttributeQuotes: true, //压缩 去掉引号
  390. removeComments: true, //移除HTML中的注释
  391. collapseWhitespace: true //删除空白符与换行符
  392. }
  393. }),
  394. new HtmlWebpackPlugin({
  395. title: 'mukuai.html',
  396. template: path.resolve(__dirname, 'src/html', 'mukuai.html'),
  397. filename: 'mukuai.html',
  398. chunks: ['mukuai', 'vendor', 'common'],
  399. hash: true, //防止缓存
  400. inject: true,
  401. minify: {
  402. removeAttributeQuotes: true, //压缩 去掉引号
  403. removeComments: true, //移除HTML中的注释
  404. collapseWhitespace: true //删除空白符与换行符
  405. }
  406. }),
  407. new HtmlWebpackPlugin({
  408. title: 'login.html',
  409. template: path.resolve(__dirname, 'src/html', 'login.html'),
  410. filename: 'login.html',
  411. chunks: ['login', 'vendor', 'common'],
  412. hash: true, //防止缓存
  413. inject: true,
  414. favicon: path.resolve('src/resource/favicon.ico'),
  415. minify: {
  416. removeAttributeQuotes: true, //压缩 去掉引号
  417. removeComments: true, //移除HTML中的注释
  418. collapseWhitespace: true //删除空白符与换行符
  419. }
  420. }),
  421. new HtmlWebpackPlugin({
  422. title: 'qcList.html',
  423. template: path.resolve(__dirname, 'src/html', 'qcList.html'),
  424. filename: 'qcList.html',
  425. chunks: ['qcList', 'vendor', 'common'],
  426. hash: true, //防止缓存
  427. inject: true,
  428. minify: {
  429. removeAttributeQuotes: true, //压缩 去掉引号
  430. removeComments: true, //移除HTML中的注释
  431. collapseWhitespace: true //删除空白符与换行符
  432. }
  433. }),
  434. new HtmlWebpackPlugin({
  435. title: 'qcListCopy.html',
  436. template: path.resolve(__dirname, 'src/html', 'qcListCopy.html'),
  437. filename: 'qcListCopy.html',
  438. chunks: ['qcListCopy', 'vendor', 'common'],
  439. hash: true, //防止缓存
  440. inject: true,
  441. minify: {
  442. removeAttributeQuotes: true, //压缩 去掉引号
  443. removeComments: true, //移除HTML中的注释
  444. collapseWhitespace: true //删除空白符与换行符
  445. }
  446. }),
  447. new HtmlWebpackPlugin({
  448. title: 'qcListOutHospital.html',
  449. template: path.resolve(__dirname, 'src/html', 'qcListOutHospital.html'),
  450. filename: 'qcListOutHospital.html',
  451. chunks: ['qcListOutHospital', 'vendor', 'common'],
  452. hash: true, //防止缓存
  453. inject: true,
  454. minify: {
  455. removeAttributeQuotes: true, //压缩 去掉引号
  456. removeComments: true, //移除HTML中的注释
  457. collapseWhitespace: true //删除空白符与换行符
  458. }
  459. }),
  460. new HtmlWebpackPlugin({
  461. title: 'qcListDocteam.html',
  462. template: path.resolve(__dirname, 'src/html', 'qcListDocteam.html'),
  463. filename: 'qcListDocteam.html',
  464. chunks: ['qcListDocteam', 'vendor', 'common'],
  465. hash: true, //防止缓存
  466. inject: true,
  467. minify: {
  468. removeAttributeQuotes: true, //压缩 去掉引号
  469. removeComments: true, //移除HTML中的注释
  470. collapseWhitespace: true //删除空白符与换行符
  471. }
  472. }),
  473. new HtmlWebpackPlugin({
  474. title: 'qcListPerson.html',
  475. template: path.resolve(__dirname, 'src/html', 'qcListPerson.html'),
  476. filename: 'qcListPerson.html',
  477. chunks: ['qcListPerson', 'vendor', 'common'],
  478. hash: true, //防止缓存
  479. inject: true,
  480. minify: {
  481. removeAttributeQuotes: true, //压缩 去掉引号
  482. removeComments: true, //移除HTML中的注释
  483. collapseWhitespace: true //删除空白符与换行符
  484. }
  485. }),
  486. new HtmlWebpackPlugin({
  487. title: 'qcListDept.html',
  488. template: path.resolve(__dirname, 'src/html', 'qcListDept.html'),
  489. filename: 'qcListDept.html',
  490. chunks: ['qcListDept', 'vendor', 'common'],
  491. hash: true, //防止缓存
  492. inject: true,
  493. minify: {
  494. removeAttributeQuotes: true, //压缩 去掉引号
  495. removeComments: true, //移除HTML中的注释
  496. collapseWhitespace: true //删除空白符与换行符
  497. }
  498. }),
  499. new HtmlWebpackPlugin({
  500. title: 'qcScore.html',
  501. template: path.resolve(__dirname, 'src/html', 'qcScore.html'),
  502. filename: 'qcScore.html',
  503. chunks: [ 'qcScore','vendor', 'common'],
  504. hash: true, //防止缓存
  505. inject: true,
  506. minify: {
  507. removeAttributeQuotes: true, //压缩 去掉引号
  508. removeComments: true, //移除HTML中的注释
  509. collapseWhitespace: true //删除空白符与换行符
  510. }
  511. }),
  512. new HtmlWebpackPlugin({
  513. title: 'statistics.html',
  514. template: path.resolve(__dirname, 'src/html', 'statistics.html'),
  515. filename: 'statistics.html',
  516. chunks: ['index', 'vendor', 'common'],
  517. hash: true, //防止缓存
  518. inject: true,
  519. minify: {
  520. removeAttributeQuotes: true, //压缩 去掉引号
  521. removeComments: true, //移除HTML中的注释
  522. collapseWhitespace: true //删除空白符与换行符
  523. }
  524. }),
  525. new HtmlWebpackPlugin({
  526. title: 'userManager.html',
  527. template: path.resolve(__dirname, 'src/html', 'userManager.html'),
  528. filename: 'userManager.html',
  529. chunks: ['userManager', 'vendor', 'common'],
  530. hash: true, //防止缓存
  531. inject: true,
  532. minify: {
  533. removeAttributeQuotes: true, //压缩 去掉引号
  534. removeComments: true, //移除HTML中的注释
  535. collapseWhitespace: true //删除空白符与换行符
  536. }
  537. }),
  538. new HtmlWebpackPlugin({
  539. title: 'roleManager.html',
  540. template: path.resolve(__dirname, 'src/html', 'roleManager.html'),
  541. filename: 'roleManager.html',
  542. chunks: ['roleManager', 'vendor', 'common'],
  543. hash: true, //防止缓存
  544. inject: true,
  545. minify: {
  546. removeAttributeQuotes: true, //压缩 去掉引号
  547. removeComments: true, //移除HTML中的注释
  548. collapseWhitespace: true //删除空白符与换行符
  549. }
  550. }),
  551. new HtmlWebpackPlugin({
  552. title: 'singleVeto.html', //单项否决详情页
  553. template: path.resolve(__dirname, 'src/html', 'singleVeto.html'),
  554. filename: 'singleVeto.html',
  555. chunks: ['singleVeto', 'vendor', 'common'],
  556. hash: true, //防止缓存
  557. inject: true,
  558. minify: {
  559. removeAttributeQuotes: true, //压缩 去掉引号
  560. removeComments: true, //移除HTML中的注释
  561. collapseWhitespace: true //删除空白符与换行符
  562. }
  563. }),
  564. new HtmlWebpackPlugin({
  565. title: 'itemDefectDetail.html', //单项否决详情页
  566. template: path.resolve(__dirname, 'src/html', 'itemDefectDetail.html'),
  567. filename: 'itemDefectDetail.html',
  568. chunks: ['itemDefectDetail', 'vendor', 'common'],
  569. hash: true, //防止缓存
  570. inject: true,
  571. minify: {
  572. removeAttributeQuotes: true, //压缩 去掉引号
  573. removeComments: true, //移除HTML中的注释
  574. collapseWhitespace: true //删除空白符与换行符
  575. }
  576. }),
  577. new HtmlWebpackPlugin({
  578. title: 'keyItemFlawControl.html', //关键条目缺陷占比
  579. template: path.resolve(__dirname, 'src/html', 'keyItemFlawControl.html'),
  580. filename: 'keyItemFlawControl.html',
  581. chunks: ['keyItemFlawControl', 'vendor', 'common'],
  582. hash: true, //防止缓存
  583. inject: true,
  584. minify: {
  585. removeAttributeQuotes: true, //压缩 去掉引号
  586. removeComments: true, //移除HTML中的注释
  587. collapseWhitespace: true //删除空白符与换行符
  588. }
  589. }),
  590. new HtmlWebpackPlugin({
  591. title: 'uncorrectedCasesStatistics.html', //未整改病历统计
  592. template: path.resolve(__dirname, 'src/html', 'uncorrectedCasesStatistics.html'),
  593. filename: 'uncorrectedCasesStatistics.html',
  594. chunks: ['uncorrectedCasesStatistics', 'vendor', 'common'],
  595. hash: true, //防止缓存
  596. inject: true,
  597. minify: {
  598. removeAttributeQuotes: true, //压缩 去掉引号
  599. removeComments: true, //移除HTML中的注释
  600. collapseWhitespace: true //删除空白符与换行符
  601. }
  602. }),
  603. new HtmlWebpackPlugin({
  604. title: 'uccDetail.html', //未整改病历统计_缺陷详情
  605. template: path.resolve(__dirname, 'src/html', 'uccDetail.html'),
  606. filename: 'uccDetail.html',
  607. chunks: ['uccDetail', 'vendor', 'common'],
  608. hash: true, //防止缓存
  609. inject: true,
  610. minify: {
  611. removeAttributeQuotes: true, //压缩 去掉引号
  612. removeComments: true, //移除HTML中的注释
  613. collapseWhitespace: true //删除空白符与换行符
  614. }
  615. }),
  616. new HtmlWebpackPlugin({
  617. title: 'readmission.html', //未整改病历统计_缺陷详情
  618. template: path.resolve(__dirname, 'src/html', 'readmission.html'),
  619. filename: 'readmission.html',
  620. chunks: ['readmission', 'vendor', 'common'],
  621. hash: true, //防止缓存
  622. inject: true,
  623. minify: {
  624. removeAttributeQuotes: true, //压缩 去掉引号
  625. removeComments: true, //移除HTML中的注释
  626. collapseWhitespace: true //删除空白符与换行符
  627. }
  628. }),
  629. new CopyWebpackPlugin([
  630. {
  631. from:'src/resource',
  632. to:path.resolve(__dirname,'dist','resource'),
  633. flatten:true, //false会拷贝原始文件夹路径
  634. }
  635. ]),
  636. new MiniCssExtractPlugin({
  637. filename: 'css/[name].css',
  638. chunkFilename: '[id].css'
  639. }),
  640. new webpack.HotModuleReplacementPlugin(),
  641. new CleanWebpackPlugin()
  642. ],
  643. optimization: { //webpack4.x的最新优化配置项,用于提取公共代码
  644. minimizer: [
  645. new UglifyJsPlugin({
  646. uglifyOptions: {
  647. ie8: true,
  648. compress: {
  649. properties: false,
  650. warnings: false
  651. },
  652. mangle: {
  653. screw_ie8: false,
  654. except: ['e']
  655. },
  656. output: {
  657. beautify: true
  658. },
  659. sourceMap: false
  660. }
  661. })
  662. ],
  663. splitChunks: {
  664. cacheGroups: {
  665. commons: {
  666. chunks: "initial",
  667. name: "common",
  668. minChunks: 2,
  669. maxInitialRequests: 5, // The default limit is too small to showcase the effect
  670. minSize: 0, // This is example is too small to create commons chunks
  671. reuseExistingChunk: true // 可设置是否重用该chunk
  672. }
  673. }
  674. }
  675. },
  676. module: {
  677. noParse: /WdatePicker/,
  678. rules: [
  679. {
  680. test: /.js$/,
  681. enforce: 'post',
  682. loader: 'es3ify-loader'
  683. },
  684. {
  685. test: /\.m?js$/,
  686. exclude: /(node_modules|bower_components)/,
  687. use: {
  688. loader: 'babel-loader',
  689. options: {
  690. presets:['@babel/preset-env']
  691. }
  692. }
  693. },
  694. {
  695. test: /\.css$/,
  696. use: [{
  697. loader: MiniCssExtractPlugin.loader
  698. },
  699. 'css-loader'
  700. ]
  701. },
  702. {
  703. test: /\.less$/,
  704. use: [{
  705. loader: MiniCssExtractPlugin.loader
  706. },
  707. 'css-loader', 'less-loader'
  708. ]
  709. },
  710. {
  711. test:/\.(png|gif|jpg|jpeg|svg|eot|ttf|woff|woff2)$/,
  712. use:[{
  713. loader:'url-loader',
  714. options:{
  715. limit:10240,
  716. esModule:false,
  717. name:'[name]_[hash:6].[ext]',
  718. outputPath:'images/'
  719. }
  720. }],
  721. exclude:/node_modules/
  722. },{
  723. test:/.html$/,
  724. use:'html-withimg-loader'
  725. }
  726. ]
  727. },
  728. // devtool: 'cheap-module-eval-source-map', //开发环境cheap-module-eval-source-map //生产环境cheap-module-source-map
  729. mode: 'development',
  730. devServer: {
  731. contentBase: "./dist", //静态文件根目录
  732. proxy: {
  733. '/': proxyHost
  734. },
  735. hot: true,
  736. openPage:'login.html'
  737. }
  738. }