| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- import * as path from "path";
- function loadSvgConfig(config, ctx) {
- // 排除 nuxt 原配置的影响,Nuxt 默认有vue-loader,会处理svg,img等
- // 找到匹配.svg的规则,然后将存放svg文件的目录排除
- const svgRule = config.module.rules.find(rule => rule.test.test(".svg"));
- svgRule.exclude = [path.resolve(__dirname, "assets/icons/svg")];
- //添加loader规则
- config.module.rules.push({
- test: /\.svg$/, // 匹配.svg
- include: [path.resolve(__dirname, "assets/icons/svg")], // 将存放svg的目录加入到loader处理目录
- use: [
- { loader: "svg-sprite-loader", options: { symbolId: "icon-[name]" } }
- ]
- });
- }
- export default {
- // Global page headers (https://go.nuxtjs.dev/config-head)
- head: {
- title: '合方圆-合天地方圆',
- meta: [
- { charset: 'utf-8' },
- { name: 'viewport', content: 'width=device-width, initial-scale=1' },
- { hid: 'description', name: 'description', content: '' }
- ],
- link: [
- { rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' },
- ]
- },
- css: [
- '@/assets/public.css'
- ],
- // Auto import components (https://go.nuxtjs.dev/config-components)
- components: true,
- // Modules for dev and build (recommended) (https://go.nuxtjs.dev/config-modules)
- buildModules: [
- '@nuxtjs/tailwindcss'
- ],
- // Modules (https://go.nuxtjs.dev/config-modules)
- modules: [
- // https://go.nuxtjs.dev/axios
- '@nuxtjs/axios',
- ],
- plugins: ["@plugins/svg-icon.js"],
- // api中间件
- serverMiddleware: [
- '~/server/index.js'
- ],
- // Axios module configuration (https://go.nuxtjs.dev/config-axios)
- axios: {
- proxy: true
- },
- proxy: {
- '/api': {
- target: 'http://szhfy.com.cn/', // 目标接口域名
- pathRewrite: {
- '^/api': '/api', // 把 /api 替换成 /
- changeOrigin: true // 表示是否跨域
- }
- },
- '/public': {
- target: 'http://szhfy.com.cn/', // 目标接口域名
- pathRewrite: {
- changeOrigin: true // 表示是否跨域
- }
- }
- },
- // Build Configuration (https://go.nuxtjs.dev/config-build)
- build: {
- extend(config, ctx) {
- loadSvgConfig(config,ctx)
- }
- },
- server: {
- port: 8000, // default: 3000
- host: '0.0.0.0', // default: localhost
- },
- generate: {
- routes:
- [
- '/product/m2m', '/product/aiCam', '/product/sm', '/product/low', '/product/cam',
- '/product/item/m2m',
- '/product/item/aiCam',
- '/product/item/sm',
- '/product/item/low',
- '/product/item/cam'
- ]
- }
- }
|