2

我在使用 React Static 的项目中的 static.config.js 文件中导入 .ts 文件时遇到问题 我收到此错误

Unexpected token { import sth from sth }

当我将我的 static.config.js 更改为 static.config.ts 时出现错误

=> File changed: /artifacts/react-static-browser-plugins.js
=> Updating build...
Failed to build! Fix any errors and try again!
multi /MY_PROJECT/node_modules/react-dev-utils/webpackHotDevClient.js (webpack)/hot/only-dev-server.js ../lib/bootstrapPlugins.js ../lib/bootstrapTemplates.js /MY_PROJECT/src/index.js
Module not found: Can't resolve '/MY_PROJECT/src/index.js' in '/MY_PROJECT/node_modules/react-static/node_modules'

我的 tsconfig.json

   "target": "esnext",
   "module": "esnext",
   "jsx": "preserve",
   "allowJs": true,
   "moduleResolution": "node",
   "allowSyntheticDefaultImports": true,
   "noImplicitAny": true,
   "noUnusedLocals": true,
   "noUnusedParameters": true,
   "removeComments": false,
   "preserveConstEnums": true,
   "sourceMap": true,
   "skipLibCheck": true,
   "baseUrl": "./src",
   "resolveJsonModule" : true,
   "lib": ["dom", "es2015", "es2016"]
}

怎么做才能在 static.config.js 中导入 .ts 文件,或者对 static.config.ts 做些什么?

4

0 回答 0