webpack.config.js 24 KB

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