webpack.config.js 22 KB

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