webpack.config.js 24 KB

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