webpack.dev.js 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. const path = require('path');
  2. const HtmlWebpackPlugin = require('html-webpack-plugin');
  3. const WebpackMerge = require('webpack-merge');
  4. const baseConfig = require('./webpack.base.js');
  5. module.exports = WebpackMerge.merge(baseConfig, {
  6. mode: 'development',
  7. //开发环境下默认启用cache,在内存中对已经构建的部分进行缓存
  8. //避免其他模块修改,但是该模块未修改时候,重新构建,能够更快的进行增量构建
  9. //属于空间换时间的做法
  10. cache: true,
  11. // 代码入口
  12. entry: {
  13. // 注册界面
  14. main: './src/main.js',
  15. },
  16. output: {
  17. path: path.resolve(__dirname, '../dist'),
  18. publicPath: '/',
  19. filename: 'app-client-[name].js',
  20. chunkFilename: 'app-client-chunk-[name].js',
  21. },
  22. watchOptions: {
  23. ignored: ['**/node_modules', '/bat/', '/dist/', '/public/', '/static/', '/test/'],
  24. poll: 2000,
  25. },
  26. devServer: {
  27. port: 8081,
  28. compress: false,
  29. // 修复BUG:Invalid Host header
  30. allowedHosts: 'all',
  31. static: [
  32. {
  33. directory: path.join(__dirname, 'client-base-v4/static'),
  34. publicPath: '/static',
  35. },
  36. {
  37. directory: path.join(__dirname, 'client-base-v4/public'),
  38. publicPath: '/',
  39. },
  40. ],
  41. // historyApiFallback: true,
  42. // historyApiFallback: {
  43. // rewrites: [
  44. // { from: /.*/, to: path.posix.join('/', 'index.html') },
  45. // ],
  46. // },
  47. headers: {
  48. 'Access-Control-Allow-Origin': '*',
  49. // eslint-disable-next-line max-len
  50. //'Content-Security-Policy': 'upgrade-insecure-requests; default-src \'none\'; base-uri \'self\'; frame-ancestors \'none\'; script-src \'self\' \'nonce-11111\'; connect-src \'self\'; form-action \'self\'; frame-src \'self\'; img-src \'self\'; font-src \'self\'; style-src \'self\' \'nonce-11111\'; manifest-src \'none\'; worker-src \'self\'; media-src \'self\'; object-src \'self\';',
  51. },
  52. proxy: {
  53. '/api': {
  54. target: 'http://wuzhixin.vip:10022/',
  55. ws: false,
  56. changeOrigin: true,
  57. secure:true,
  58. },
  59. '/static': {
  60. target: 'http://wuzhixin.vip:10022/',
  61. ws: false,
  62. changeOrigin: true,
  63. secure:true,
  64. },
  65. '/content': {
  66. target: 'http://wuzhixin.vip:10022/',
  67. ws: false,
  68. changeOrigin: true,
  69. secure:true,
  70. },
  71. '/dashboard': {
  72. target: 'http://wuzhixin.vip:10022/',
  73. ws: false,
  74. changeOrigin: true,
  75. secure:true,
  76. },
  77. '/assets': {
  78. target: 'http://wuzhixin.vip:10022/',
  79. ws: false,
  80. changeOrigin: true,
  81. secure:true,
  82. },
  83. '/mock': {
  84. target: 'http://wuzhixin.vip:10022/',
  85. ws: false,
  86. changeOrigin: true,
  87. secure:true,
  88. },
  89. '/authApi': {
  90. target: 'http://wuzhixin.vip:10022/',
  91. ws: false,
  92. changeOrigin: true,
  93. secure:true,
  94. },
  95. '/Dictionary': {
  96. target: 'http://wuzhixin.vip:10022/',
  97. ws: false,
  98. changeOrigin: true,
  99. secure:true,
  100. },
  101. '/Files': {
  102. target: 'http://wuzhixin.vip:10022/',
  103. ws: false,
  104. changeOrigin: true,
  105. secure:true,
  106. },
  107. '/WebSocket': {
  108. target: 'http://wuzhixin.vip:10022/',
  109. ws: true,
  110. changeOrigin: true,
  111. },
  112. '/TrainVideo': {
  113. target: 'http://wuzhixin.vip:10022/',
  114. ws: true,
  115. changeOrigin: true,
  116. },
  117. '/gateway-api': {
  118. target: 'http://wuzhixin.vip:10022/',
  119. ws: true,
  120. changeOrigin: true,
  121. secure:true,
  122. },
  123. },
  124. },
  125. devtool: 'source-map',
  126. plugins: (module.exports.plugins || []).concat([
  127. new HtmlWebpackPlugin({
  128. title: 'Prodog',
  129. template: './public/index-debug.html', // 源模板文件
  130. filename: './index.html', // 输出文件【注意:这里的根路径是module.exports.output.path】
  131. chunks: ['main'],
  132. }),
  133. ]),
  134. });