0

这是 nuxt 配置:

export default {
  head: {
    htmlAttrs: {
      lang: "en",
    },
    meta: [
      { charset: "utf-8" },

    ],
    link: [
      { rel: "icon", type: "image/x-icon", href: "/favicon.ico" },
      {
        rel: "stylesheet",
        href: "./css/bootstrap.min.css",
      },
      {
        rel: "stylesheet",
        href: "./css/plugins.css",
      },
      {
        rel: "stylesheet",
        href: "./css/magnific-popup.css",
      },
      {
        rel: "stylesheet",
        href: "./css/aos.css",
      },
      {
        rel: "stylesheet",
        href: "./css/style.css",
      },
      {
        rel: "stylesheet",
        href: "./css/styles/maincolors.css",
      },
    ],
    script: [
      {
        src: "./js/bootstrap.bundle.min.js",
        body: true,
      },
      {
        src: "./js/imagesloaded.pkgd.min.js",
        body: true,
      },
      {
        src: "./js/isotope.pkgd.min.js",
        body: true,
      },
      {
        src: "./js/jquery.magnific-popup.min.js",
        body: true,
      },
      {
        src: "./js/easing.min.js",
        body: true,
      },
      {
        src: "./js/aos.js",
        body: true,
      },
      {
        src: "./js/custom-nuxt.js",
        body: true,
      },
    ],
    bodyAttrs: {
      id: "top",
    },
  },

  // Global CSS: https://go.nuxtjs.dev/config-css
  css: [
    // "~/static/css/bootstrap.min.css",
    // "~/static/css/plugins.css",
    // "~/static/css/magnific-popup.css",
    // "~/static/css/aos.css",
    // "~/static/css/style.css",
    // "~/static/css/styles/maincolors.css",
  ],
  //Global JS
  //   script: [
  // "~assets/js/custom.js"
  //   ],

  // Plugins to run before rendering page: https://go.nuxtjs.dev/config-plugins
  plugins: [],

  // Auto import components: https://go.nuxtjs.dev/config-components
  components: {
    path: "~/components", // will get any components nested in let's say /components/test too
    pathPrefix: false,
  },

  // Modules for dev and build (recommended): https://go.nuxtjs.dev/config-modules
  buildModules: [],

  // Modules: https://go.nuxtjs.dev/config-modules
  modules: [
    // https://go.nuxtjs.dev/axios
    "@nuxtjs/axios",
  ],

  // Axios module configuration: https://go.nuxtjs.dev/config-axios
  axios: {
    // Workaround to avoid enforcing hard-coded localhost:3000: https://github.com/nuxt-community/axios-module/issues/308
    baseURL: "https://example.test/api",
    retry: { retries: 3 },
  },
  publicRuntimeConfig: {
    axios: {
      baseURL: "https://example.test/api",
    },
  },
  publicRuntimeConfig: {
    axios: {
      baseURL: "https://example.test/api",
    },
  },

  // Build Configuration: https://go.nuxtjs.dev/config-build
  build: {
    extractCSS: true,
  },
};

现在,当我运行npm run generate并检查 dist 文件夹时,主页上的 css 加载正常,除了主页,它没有找到 css。基本上,在检查控制台时,我注意到其他页面正在查看 csshttp://example.com/page/css/filename.css

即,/page/ 当前页面的 slug 也得到了后缀,这就是它找不到 css 的原因。

顺便说一下,这些css是在/static/*文件夹下加载的。

4

0 回答 0