webpack.config.js 27 KB

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