webpack.dev.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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. static: [
  30. {
  31. directory: path.join(__dirname, 'client-base-v4/static'),
  32. publicPath: '/static',
  33. },
  34. {
  35. directory: path.join(__dirname, 'client-base-v4/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: 'http://localhost:83/',
  53. ws: false,
  54. changeOrigin: true,
  55. secure:true,
  56. },
  57. '/authApi': {
  58. target: 'http://localhost:83/',
  59. ws: false,
  60. changeOrigin: true,
  61. secure:true,
  62. },
  63. '/Dictionary': {
  64. target: 'http://localhost:83/',
  65. ws: false,
  66. changeOrigin: true,
  67. secure:true,
  68. },
  69. '/Files': {
  70. target: 'http://localhost:83/',
  71. ws: false,
  72. changeOrigin: true,
  73. secure:true,
  74. },
  75. '/WebSocket': {
  76. target: 'http://localhost:83/',
  77. ws: true,
  78. changeOrigin: true,
  79. },
  80. '/TrainVideo': {
  81. target: 'http://localhost:83/',
  82. ws: true,
  83. changeOrigin: true,
  84. },
  85. '/gateway-api': {
  86. target: 'http://localhost:83/',
  87. ws: true,
  88. changeOrigin: true,
  89. secure:true,
  90. },
  91. },
  92. },
  93. devtool: 'source-map',
  94. plugins: (module.exports.plugins || []).concat([
  95. new HtmlWebpackPlugin({
  96. title: 'Prodog',
  97. template: './client-base-v4/static/htmls/template-debug.html', // 源模板文件
  98. filename: './index.html', // 输出文件【注意:这里的根路径是module.exports.output.path】
  99. chunks: ['main'],
  100. }),
  101. ]),
  102. });