webpack.config.js 25 KB

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