webpack.dev.js 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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. main: path.resolve(__dirname, './src/main.js'),
  19. },
  20. output: {
  21. path: path.resolve(__dirname, '../dist'),
  22. publicPath: '/',
  23. filename: 'app-client-yidong-[name].js',
  24. chunkFilename: 'app-client-yidong-chunk-[name].js',
  25. },
  26. devServer: {
  27. port: 8084,
  28. https: false,
  29. static: [
  30. {
  31. directory: path.join(__dirname, 'src-eam/static-eam-app'),
  32. publicPath: '/static-eam-app',
  33. },
  34. {
  35. directory: path.join(__dirname, 'src-wms/static-wms-app'),
  36. publicPath: '/static-wms-app',
  37. },
  38. {
  39. directory: path.join(__dirname, 'public'),
  40. publicPath: '/',
  41. },
  42. ],
  43. // historyApiFallback: true,
  44. // historyApiFallback: {
  45. // rewrites: [
  46. // { from: /.*/, to: path.posix.join('/', 'index.html') },
  47. // ],
  48. // },
  49. headers: {
  50. 'Access-Control-Allow-Origin': '*',
  51. },
  52. proxy: {
  53. '/api': {
  54. target: 'http://192.168.1.122:10026/',
  55. ws: false,
  56. changeOrigin: true,
  57. },
  58. '/authApi': {
  59. target: 'http://192.168.1.122:10026/',
  60. ws: false,
  61. changeOrigin: true,
  62. },
  63. '/Dictionary': {
  64. target: 'http://192.168.1.122:10026/',
  65. ws: false,
  66. changeOrigin: true,
  67. },
  68. '/Files': {
  69. target: 'http://192.168.1.122:10026/',
  70. ws: false,
  71. changeOrigin: true,
  72. },
  73. '/static': {
  74. target: 'http://192.168.1.122:10026/',
  75. ws: false,
  76. changeOrigin: true,
  77. },
  78. '/static-app': {
  79. target: 'http://192.168.1.122:10026/',
  80. ws: false,
  81. changeOrigin: true,
  82. },
  83. '/android-device-sdk': {
  84. target: 'http://192.168.1.122:10026/',
  85. ws: false,
  86. changeOrigin: true,
  87. },
  88. },
  89. },
  90. devtool: 'source-map',
  91. plugins: (module.exports.plugins || []).concat([
  92. new HtmlWebpackPlugin({
  93. title: 'Prodog App',
  94. template: './public/index-debug.html', // 源模板文件
  95. filename: './app.html', // 输出文件【注意:这里的根路径是module.exports.output.path】
  96. chunks: ['main'],
  97. }),
  98. ]),
  99. });