webpack.dev.js 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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: 8083,
  28. compress: false,
  29. static: [
  30. {
  31. directory: path.join(__dirname, 'client-base-v3/static'),
  32. publicPath: '/static',
  33. },
  34. {
  35. directory: path.join(__dirname, 'client-base-v3/public'),
  36. publicPath: '/',
  37. },
  38. ],
  39. // historyApiFallback: true,
  40. // historyApiFallback: {
  41. // rewrites: [
  42. // { from: /.*/, to: path.posix.join('/', 'index.html') },
  43. // ],
  44. // },
  45. headers: {
  46. 'Access-Control-Allow-Origin': '*',
  47. // eslint-disable-next-line max-len
  48. //'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\';',
  49. },
  50. proxy: {
  51. '/api': {
  52. target: 'https://a.leanwo.com:11022/',
  53. ws: false,
  54. changeOrigin: true,
  55. secure:true,
  56. },
  57. '/static': {
  58. target: 'https://a.leanwo.com:11022/',
  59. ws: false,
  60. changeOrigin: true,
  61. secure:true,
  62. },
  63. '/dashboard': {
  64. target: 'https://a.leanwo.com:11022/',
  65. ws: false,
  66. changeOrigin: true,
  67. secure:true,
  68. },
  69. '/mock': {
  70. target: 'https://a.leanwo.com:11022/',
  71. ws: false,
  72. changeOrigin: true,
  73. secure:true,
  74. },
  75. '/authApi': {
  76. target: 'https://a.leanwo.com:11022/',
  77. ws: false,
  78. changeOrigin: true,
  79. secure:true,
  80. },
  81. '/Dictionary': {
  82. target: 'https://a.leanwo.com:11022/',
  83. ws: false,
  84. changeOrigin: true,
  85. secure:true,
  86. },
  87. '/Files': {
  88. target: 'https://a.leanwo.com:11022/',
  89. ws: false,
  90. changeOrigin: true,
  91. secure:true,
  92. },
  93. '/WebSocket': {
  94. target: 'https://a.leanwo.com:11022/',
  95. ws: true,
  96. changeOrigin: true,
  97. },
  98. '/TrainVideo': {
  99. target: 'https://a.leanwo.com:11022/',
  100. ws: true,
  101. changeOrigin: true,
  102. },
  103. '/gateway-api': {
  104. target: 'https://a.leanwo.com:11022/',
  105. ws: true,
  106. changeOrigin: true,
  107. secure:true,
  108. },
  109. },
  110. },
  111. devtool: 'source-map',
  112. plugins: (module.exports.plugins || []).concat([
  113. new HtmlWebpackPlugin({
  114. title: 'Prodog',
  115. template: './public/index.html', // 源模板文件
  116. filename: './index.html', // 输出文件【注意:这里的根路径是module.exports.output.path】
  117. chunks: ['main'],
  118. }),
  119. ]),
  120. });