webpack.config.js 21 KB

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