index.js 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. 'use strict'
  2. const path = require('path')
  3. module.exports = {
  4. dev: {
  5. // Paths
  6. assetsSubDirectory: 'static',
  7. assetsPublicPath: '/',
  8. proxyTable: {
  9. '/api': {
  10. target: 'http://127.0.0.1:8082', //设置调用接口地址和端口号别忘了加http
  11. changeOrigin: true,
  12. pathRewrite: {
  13. '^/api': '/' //这里理解成用‘/api’代替target里面的地址,组件中我们调接口时直接用/api代替
  14. // 比如我要调用'http://0.0:300/user/add',直接写‘/api/user/add’即可 代理后地址栏显示/
  15. }
  16. }
  17. },
  18. // Various Dev Server settings
  19. host: 'localhost', // can be overwritten by process.env.HOST
  20. port: 9528, // can be overwritten by process.env.PORT, if port is in use, a free one will be determined
  21. autoOpenBrowser: true,
  22. errorOverlay: true,
  23. notifyOnErrors: false,
  24. poll: false, // https://webpack.js.org/configuration/dev-server/#devserver-watchoptions-
  25. // Use Eslint Loader?
  26. // If true, your code will be linted during bundling and
  27. // linting errors and warnings will be shown in the console.
  28. useEslint: true,
  29. // If true, eslint errors and warnings will also be shown in the error overlay
  30. // in the browser.
  31. showEslintErrorsInOverlay: false,
  32. /**
  33. * Source Maps
  34. */
  35. // https://webpack.js.org/configuration/devtool/#development
  36. devtool: 'cheap-source-map',
  37. // CSS Sourcemaps off by default because relative paths are "buggy"
  38. // with this option, according to the CSS-Loader README
  39. // (https://github.com/webpack/css-loader#sourcemaps)
  40. // In our experience, they generally work as expected,
  41. // just be aware of this issue when enabling this option.
  42. cssSourceMap: false
  43. },
  44. build: {
  45. // Template for index.html
  46. index: path.resolve(__dirname, '../dist/index.html'),
  47. // Paths
  48. assetsRoot: path.resolve(__dirname, '../dist'),
  49. assetsSubDirectory: 'static',
  50. /**
  51. * You can set by youself according to actual condition
  52. * You will need to set this if you plan to deploy your site under a sub path,
  53. * for example GitHub pages. If you plan to deploy your site to https://foo.github.io/bar/,
  54. * then assetsPublicPath should be set to "/bar/".
  55. * In most cases please use '/' !!!
  56. */
  57. assetsPublicPath: '/', // If you are deployed on the root path, please use '/'
  58. /**
  59. * Source Maps
  60. */
  61. productionSourceMap: false,
  62. // https://webpack.js.org/configuration/devtool/#production
  63. devtool: 'source-map',
  64. // Gzip off by default as many popular static hosts such as
  65. // Surge or Netlify already gzip all static assets for you.
  66. // Before setting to `true`, make sure to:
  67. // npm install --save-dev compression-webpack-plugin
  68. productionGzip: false,
  69. productionGzipExtensions: ['js', 'css'],
  70. // Run the build command with an extra argument to
  71. // View the bundle analyzer report after build finishes:
  72. // `npm run build --report`
  73. // Set to `true` or `false` to always turn it on or off
  74. bundleAnalyzerReport: process.env.npm_config_report || false,
  75. // `npm run build:prod --generate_report`
  76. generateAnalyzerReport: process.env.npm_config_generate_report || false
  77. }
  78. }