vue.config.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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. config.module.rule('images').use('url-loader')
  46. .loader('url-loader')
  47. .options({
  48. limit: 1024, //1KB以下使用base64
  49. name: 'img/[name].[hash:8].[ext]'
  50. })
  51. // svg图标
  52. config.module.rule('svg').exclude.add(resolve('src/components/svgs')).end()
  53. config.module.rule('icons').test(/\.svg$/).include.add(resolve('src/components/svgs')).end()
  54. .use('svg-sprite-loader').loader('svg-sprite-loader').options({
  55. symbolId: 'icon-[name]'
  56. }).end()
  57. },
  58. // 设为false打包时不生成.map文件
  59. productionSourceMap: false,
  60. // 这里写你调用接口的基础路径,来解决跨域,如果设置了代理,那你本地开发环境的axios的baseUrl要写为 '' ,即空字符串
  61. devServer: {
  62. // proxy: 'http://127.0.0.1:8888',
  63. proxy: {
  64. '/file': {
  65. target: 'https://s.dev01.dkiboss.com:6010/file/', //后台服务器的ip地址
  66. pathRewrite: { '^/file': '/' },
  67. changeOrigin: true
  68. }
  69. }
  70. // proxyTable: {
  71. // '/api': {
  72. // target: 'http://localhost:8888',
  73. // changeOrigin: true,
  74. // pathRewrite: {
  75. // '^/api': ''
  76. // }
  77. // }
  78. // }
  79. },
  80. configureWebpack: config => {
  81. // 为生产环境修改配置...
  82. if (process.env.NODE_ENV === 'production') {
  83. config.mode = 'production'
  84. // 打包文件大小配置
  85. config.performance = {
  86. maxEntrypointSize: 10000000,
  87. maxAssetSize: 30000000
  88. }
  89. }
  90. },
  91. }
  92. //test branches