IAm*_*ing 4 typescript netlify netlify-cms
我正在尝试gatsby-plugin-netlify-cms与 Gatsby typescript 集成,每次尝试构建网站时,都会收到以下错误消息。
“您可能需要适当的加载程序来处理此文件类型,目前没有配置加载程序来处理此文件。”
我的gatsby-config.js文件写如下,
module.exports = {
/* Your site config here */
plugins: [
`gatsby-plugin-styled-components`,
{
resolve: `gatsby-plugin-netlify-cms`,
options: {
modulePath: `${__dirname}/src/cms/cms.ts`,
},
},
{
resolve: `gatsby-source-filesystem`,
options: {
name: `markdown-pages`,
path: `${__dirname}/src/pages`,
},
},
`gatsby-plugin-sharp`,
{
resolve: `gatsby-transformer-remark`,
options: {
plugins: [
{
resolve: `gatsby-remark-images`,
options: {
maxWidth: 512,
},
},
],
},
},
`gatsby-plugin-netlify`,
],
};
Run Code Online (Sandbox Code Playgroud)
我能够让 Typescript 为我的项目的其余部分工作,但只有当我尝试修改预览模板时,它才开始失败。具体来说,当我编写以下代码时,一切都崩溃了gatsby-plugin-netlify-cms。
options: {
modulePath: `${__dirname}/src/cms/cms.ts`,
},
Run Code Online (Sandbox Code Playgroud)
为什么我收到错误消息?
为遇到此错误的其他人关闭此操作。我将以下代码行添加到文件中gatsby-config.js。
plugins: [
{
resolve: 'gatsby-plugin-typescript',
options: {
isTSX: true,
allExtensions: true,
},
},
]
Run Code Online (Sandbox Code Playgroud)
这为我解决了错误。
| 归档时间: |
|
| 查看次数: |
441 次 |
| 最近记录: |