nuxt.config.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. import * as path from "path";
  2. function loadSvgConfig(config, ctx) {
  3. // 排除 nuxt 原配置的影响,Nuxt 默认有vue-loader,会处理svg,img等
  4. // 找到匹配.svg的规则,然后将存放svg文件的目录排除
  5. const svgRule = config.module.rules.find(rule => rule.test.test(".svg"));
  6. svgRule.exclude = [path.resolve(__dirname, "assets/icons/svg")];
  7. //添加loader规则
  8. config.module.rules.push({
  9. test: /\.svg$/, // 匹配.svg
  10. include: [path.resolve(__dirname, "assets/icons/svg")], // 将存放svg的目录加入到loader处理目录
  11. use: [
  12. { loader: "svg-sprite-loader", options: { symbolId: "icon-[name]" } }
  13. ]
  14. });
  15. }
  16. export default {
  17. // Global page headers (https://go.nuxtjs.dev/config-head)
  18. head: {
  19. title: '合方圆-合天地方圆',
  20. meta: [
  21. { charset: 'utf-8' },
  22. { name: 'viewport', content: 'width=device-width, initial-scale=1' },
  23. { hid: 'description', name: 'description', content: '' }
  24. ],
  25. link: [
  26. { rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' },
  27. ]
  28. },
  29. css: [
  30. '@/assets/public.css'
  31. ],
  32. // Auto import components (https://go.nuxtjs.dev/config-components)
  33. components: true,
  34. // Modules for dev and build (recommended) (https://go.nuxtjs.dev/config-modules)
  35. buildModules: [
  36. '@nuxtjs/tailwindcss'
  37. ],
  38. // Modules (https://go.nuxtjs.dev/config-modules)
  39. modules: [
  40. // https://go.nuxtjs.dev/axios
  41. '@nuxtjs/axios',
  42. // '@nuxtjs/style-resources',
  43. ],
  44. plugins: ["@plugins/svg-icon.js"],
  45. // api中间件
  46. serverMiddleware: [
  47. '~/server/index.js'
  48. ],
  49. // styleResources: {
  50. // scss: [
  51. // '~/assets/_var.scss'
  52. // ]
  53. // },
  54. // Axios module configuration (https://go.nuxtjs.dev/config-axios)
  55. axios: {
  56. proxy: true
  57. },
  58. proxy: {
  59. '/api': {
  60. target: 'http://szhfy.com.cn/', // 目标接口域名
  61. pathRewrite: {
  62. '^/api': '/api', // 把 /api 替换成 /
  63. changeOrigin: true // 表示是否跨域
  64. }
  65. },
  66. '/public': {
  67. target: 'http://szhfy.com.cn/', // 目标接口域名
  68. pathRewrite: {
  69. changeOrigin: true // 表示是否跨域
  70. }
  71. },
  72. '/Public': {
  73. target: 'http://szhfy.com.cn/', // 目标接口域名
  74. pathRewrite: {
  75. changeOrigin: true // 表示是否跨域
  76. }
  77. }
  78. },
  79. // Build Configuration (https://go.nuxtjs.dev/config-build)
  80. build: {
  81. extend(config, ctx) {
  82. loadSvgConfig(config,ctx)
  83. }
  84. },
  85. server: {
  86. port: 8000, // default: 3000
  87. host: '0.0.0.0', // default: localhost
  88. },
  89. generate: {
  90. routes:
  91. [
  92. '/product/m2m', '/product/aiCam', '/product/sm', '/product/low', '/product/cam',
  93. '/product/item/m2m',
  94. '/product/item/aiCam',
  95. '/product/item/sm',
  96. '/product/item/low',
  97. '/product/item/cam'
  98. ]
  99. }
  100. }