nuxt.config.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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: [
  45. "@plugins/svg-icon.js",
  46. {src: '~/plugins/vue-pdf.js', ssr: false}
  47. ],
  48. // api中间件
  49. serverMiddleware: [
  50. '~/server/index.js'
  51. ],
  52. // styleResources: {
  53. // scss: [
  54. // '~/assets/_var.scss'
  55. // ]
  56. // },
  57. // Axios module configuration (https://go.nuxtjs.dev/config-axios)
  58. axios: {
  59. proxy: true
  60. },
  61. proxy: {
  62. '/api': {
  63. target: 'http://szhfy.com.cn/', // 目标接口域名
  64. pathRewrite: {
  65. '^/api': '/api', // 把 /api 替换成 /
  66. changeOrigin: true // 表示是否跨域
  67. }
  68. },
  69. '/public': {
  70. target: 'http://szhfy.com.cn/', // 目标接口域名
  71. pathRewrite: {
  72. changeOrigin: true // 表示是否跨域
  73. }
  74. },
  75. '/Public': {
  76. target: 'http://szhfy.com.cn/', // 目标接口域名
  77. pathRewrite: {
  78. changeOrigin: true // 表示是否跨域
  79. }
  80. }
  81. },
  82. // Build Configuration (https://go.nuxtjs.dev/config-build)
  83. build: {
  84. extend(config, ctx) {
  85. loadSvgConfig(config,ctx)
  86. }
  87. },
  88. server: {
  89. port: 8000, // default: 3000
  90. host: '0.0.0.0', // default: localhost
  91. },
  92. generate: {
  93. routes:
  94. [
  95. '/product/m2m', '/product/aiCam', '/product/sm', '/product/low', '/product/cam',
  96. '/product/item/m2m',
  97. '/product/item/aiCam',
  98. '/product/item/sm',
  99. '/product/item/low',
  100. '/product/item/cam',
  101. '/solution/sol',
  102. '/solution/acs',
  103. '/solution/epower',
  104. '/news/com',
  105. '/news/pa',
  106. '/news/in',
  107. '/news/item/com',
  108. '/news/item/pa',
  109. '/news/item/in',
  110. ]
  111. }
  112. }