vue.config.js 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. const packageName = require('./package.json').name
  2. console.log(packageName)
  3. module.exports = {
  4. //路径前缀
  5. //打包配置,解决页面空白的配置方案。
  6. lintOnSave: true,
  7. runtimeCompiler: true,
  8. productionSourceMap: false,
  9. chainWebpack: (config) => {
  10. config.module
  11. .rule('fonts')
  12. .test(/.(ttf|otf|eot|woff|woff2)$/)
  13. .use('url-loader')
  14. .loader('url-loader')
  15. .tap((options) => {
  16. options = {
  17. // limit: 10000,
  18. name: '/static/fonts/[name].[ext]',
  19. }
  20. return options
  21. })
  22. },
  23. // chainWebpack: (config) => {
  24. // 忽略的打包文件
  25. // config.externals({
  26. // 'vue': 'Vue',
  27. // 'vue-router': 'VueRouter',
  28. // 'vuex': 'Vuex',
  29. // 'axios': 'axios',b
  30. // 'element-ui': 'ELEMENT',
  31. // });
  32. // const entry = config.entry('app');
  33. // entry.add('babel-polyfill').end();
  34. // entry.add('classlist-polyfill').end();
  35. // entry.add('@/mock').end();
  36. // },
  37. css: {
  38. extract: { ignoreOrder: true },
  39. },
  40. //开发模式反向代理配置,生产模式请使用Nginx部署并配置反向代理
  41. devServer: {
  42. port: 1777,
  43. headers: {
  44. 'Access-Control-Allow-Origin': '*',
  45. },
  46. proxy: {
  47. '/api': {
  48. //本地服务接口地址
  49. target: 'http://36.134.91.96:10001/api',
  50. // target: 'https://cfm.bytesail.cn/api',
  51. //远程演示服务地址,可用于直接启动项目
  52. //target: 'https://saber.bladex.vip/api',
  53. ws: true,
  54. pathRewrite: {
  55. '^/api': '/',
  56. },
  57. },
  58. '/file': {
  59. //本地服务接口地址
  60. target: 'http://36.134.91.96:10001',
  61. // target: 'https://cfm.bytesail.cn/api',
  62. //远程演示服务地址,可用于直接启动项目
  63. //target: 'https://saber.bladex.vip/api',
  64. ws: true,
  65. pathRewrite: {
  66. '^/api': '/',
  67. },
  68. },
  69. },
  70. },
  71. // 自定义webpack配置
  72. configureWebpack: {
  73. output: {
  74. library: `${packageName}-[name]`,
  75. libraryTarget: 'umd',
  76. jsonpFunction: `webpackJsonp_${packageName}`,
  77. },
  78. },
  79. }