Gatsby 阴影组件时如何处理导入

Gatsby 阴影组件时如何处理导入,gatsby,Gatsby,当隐藏盖茨比主题时,如何处理对不需要任何更改的组件的导入调用。据我所知,如果要进行阴影处理,则目录中应该存在的唯一文件是您希望更改的组件的源代码 例如,在original index.js中,我有以下导入 import { graphql } from "gatsby" import React from "react" import CustomFonts from "../components/custom-fonts/custom-font

当隐藏盖茨比主题时,如何处理对不需要任何更改的组件的导入调用。据我所知,如果要进行阴影处理,则目录中应该存在的唯一文件是您希望更改的组件的源代码

例如,在original index.js中,我有以下导入

import { graphql } from "gatsby"
import React from "react"
import CustomFonts from "../components/custom-fonts/custom-fonts"
import Footer from "../components/footer/footer"
import Header from "../components/header/header"
import SEO from "../components/seo/seo"
import Sidebar from "../components/sidebar/sidebar"
import "../styles/style.css"
如果我想隐藏index.js,我将如何导入这些组件?或者所有的进口产品都必须在当地生产

我想这是盖茨比关于这个的相关文件,但我还是有些困惑,读完后


任何帮助都将不胜感激

事实证明这是一个非常愚蠢的问题,只需使用gatsby config.js下的插件解析路径

@CrustyWang的答案是正确的……但下面是如何在代码中实现它

假设您的
node_modules
中有一个模块
fontcula
,其路径上有以下样式文件-
node\u模块/fontcula/src/styles/

  • 索引
  • 环球旅行社
  • 媒体
其中index.ts是-

import { media } from "@styles/media";

export { globalStyles, media };
假设我们想在文件
font.ts
中添加一组新字体,我们想从index.ts导出该文件。要做到这一点,我们需要做以下几点-

  • 在路径
    project\u folder/src/fontula/styles
    add font.ts并添加需要添加的内容

  • 在同一路径上重新创建index.ts作为-

  • 你可以走了


    操作部分从
    node\u modules
    文件夹中的
    globalStyles
    media
    源文件中拉入
    globalStyles
    ,我遇到了同样的问题。它只是给了我一个本地模块不存在的“无法解决”错误。你能详细说明你为“解决”这个问题所采取的步骤吗?
    import { globalStyles } from "fontcula/src/styles/global";
    import { media } from "fontcula/src/styles/media";
    import { fonts } from "./fonts"
    
    export { globalStyles, fonts, media };