webpack.config.js 22 KB

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