webpack.config.js 23 KB

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