webpack.dev.js 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. const path = require('path')
  2. const webpack = require('webpack')
  3. const fs = require('fs');
  4. const MiniCssExtractPlugin = require('mini-css-extract-plugin')
  5. const { VueLoaderPlugin } = require('vue-loader')
  6. const HtmlWebpackPlugin = require('html-webpack-plugin');
  7. const ESLintPlugin = require('eslint-webpack-plugin');
  8. const WebpackMerge = require('webpack-merge')
  9. const baseConfig = require('./webpack.base.js')
  10. module.exports = WebpackMerge.merge(baseConfig, {
  11. mode: 'development',
  12. //开发环境下默认启用cache,在内存中对已经构建的部分进行缓存
  13. //避免其他模块修改,但是该模块未修改时候,重新构建,能够更快的进行增量构建
  14. //属于空间换时间的做法
  15. cache: true,
  16. // 代码入口
  17. entry: {
  18. wmsapp: path.resolve(__dirname, './src/index.js'),
  19. },
  20. output: {
  21. path: path.resolve(__dirname, '../dist'),
  22. publicPath: '/',
  23. filename: 'eamapp-[name].js',
  24. chunkFilename: 'eamapp-chunk-[name].js',
  25. },
  26. devServer: {
  27. port: 8083,
  28. static: [
  29. {
  30. directory: path.join(__dirname, 'static-eam-app'),
  31. publicPath: '/static-eam-app',
  32. }
  33. ],
  34. // historyApiFallback: true,
  35. // historyApiFallback: {
  36. // rewrites: [
  37. // { from: /.*/, to: path.posix.join('/', 'index.html') },
  38. // ],
  39. // },
  40. headers: {
  41. 'Access-Control-Allow-Origin': '*',
  42. },
  43. proxy: {
  44. '/api': {
  45. target: 'http://localhost:83/',
  46. ws: false,
  47. changeOrigin: true
  48. },
  49. '/authApi': {
  50. target: 'http://localhost:83/',
  51. ws: false,
  52. changeOrigin: true
  53. },
  54. '/Dictionary': {
  55. target: 'http://localhost:83/',
  56. ws: false,
  57. changeOrigin: true
  58. },
  59. '/Files': {
  60. target: 'http://localhost:83/',
  61. ws: false,
  62. changeOrigin: true
  63. },
  64. },
  65. },
  66. devtool: 'source-map',
  67. plugins: (module.exports.plugins || []).concat([
  68. new HtmlWebpackPlugin({
  69. title: 'Prodog',
  70. template: './static-eam-app/index.html', // 源模板文件
  71. filename: './index.html', // 输出文件【注意:这里的根路径是module.exports.output.path】
  72. chunks: ['wmsapp']
  73. })
  74. ])
  75. })