vue.config.js 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. const path = require('path')
  2. const webpack = require('webpack')
  3. if (process.env.NODE_ENV === 'prod') {
  4. }
  5. const resolve = dir => {
  6. return path.join(__dirname, dir)
  7. }
  8. // 项目部署基础
  9. // 默认情况下,我们假设你的应用将被部署在域的根目录下,
  10. // 例如:https://www.my-app.com/
  11. // 默认:'/'
  12. // 如果您的应用程序部署在子路径中,则需要在这指定子路径
  13. // 例如:https://www.foobar.com/my-app/
  14. // 需要将它改为'/my-app/'
  15. // iview-admin线上演示打包路径: https://file.iviewui.com/admin-dist/
  16. // const BASE_URL = process.env.NODE_ENV === 'production'
  17. const BASE_URL = process.env.NODE_ENV === 'development'
  18. ? '/'
  19. //pad
  20. // : '././'
  21. //web
  22. : '/'
  23. module.exports = {
  24. // Project deployment base
  25. // By default we assume your app will be deployed at the root of a domain,
  26. // e.g. https://www.my-app.com/
  27. // If your app is deployed at a sub-path, you will need to specify that
  28. // sub-path here. For example, if your app is deployed at
  29. // https://www.foobar.com/my-app/
  30. // then change this to '/my-app/'
  31. // baseUrl: BASE_URL,
  32. publicPath: BASE_URL,
  33. // tweak internal webpack configuration.
  34. // see https://github.com/vuejs/vue-cli/blob/dev/docs/webpack.md
  35. // 如果你不需要使用eslint,把lintOnSave设为false即可 es6
  36. lintOnSave: false,
  37. chainWebpack: config => {
  38. config.resolve.alias
  39. .set('@', resolve('src')) // key,value自行定义,比如.set('@@', resolve('src/components'))
  40. .set('_c', resolve('src/components'))
  41. config.plugin('provide').use(webpack.ProvidePlugin,[{
  42. 'window.Quill': 'quill/dist/quill.js',
  43. 'Quill': 'quill/dist/quill.js'
  44. }])
  45. // svg图标
  46. config.module.rule('svg').exclude.add(resolve('src/components/svgs')).end()
  47. config.module.rule('icons').test(/\.svg$/).include.add(resolve('src/components/svgs')).end()
  48. .use('svg-sprite-loader').loader('svg-sprite-loader').options({
  49. symbolId: 'icon-[name]'
  50. }).end()
  51. },
  52. // 设为false打包时不生成.map文件
  53. productionSourceMap: false,
  54. // 这里写你调用接口的基础路径,来解决跨域,如果设置了代理,那你本地开发环境的axios的baseUrl要写为 '' ,即空字符串
  55. devServer: {
  56. // proxy: 'http://127.0.0.1:8888',
  57. proxy: {
  58. '/file': {
  59. target: 'https://s.dev01.dkiboss.com:6010/file/', //后台服务器的ip地址
  60. pathRewrite: { '^/file': '/' },
  61. changeOrigin: true
  62. }
  63. }
  64. // proxyTable: {
  65. // '/api': {
  66. // target: 'http://localhost:8888',
  67. // changeOrigin: true,
  68. // pathRewrite: {
  69. // '^/api': ''
  70. // }
  71. // }
  72. // }
  73. },
  74. configureWebpack: config => {
  75. // 为生产环境修改配置...
  76. if (process.env.NODE_ENV === 'production') {
  77. config.mode = 'production'
  78. // 打包文件大小配置
  79. config.performance = {
  80. maxEntrypointSize: 10000000,
  81. maxAssetSize: 30000000
  82. }
  83. }
  84. },
  85. }
  86. //test branches