razzle-plugin-typescript
此程序包包含用于将 TypeScript 与 Razzle 配合使用的插件
Razzle 现在支持使用 babel 的 typescript。除非您特别需要这个插件,否则我们建议使用内置的支持
在 Razzle 项目中使用
yarn add razzle-plugin-typescript
使用具有默认选项的插件
// razzle.config.jsmodule.exports = { plugins: ['typescript'],};
在 typescript 示例项目 中查看完整配置。
使用自定义选项:
// razzle.config.jsmodule.exports = { plugins: [ { name: 'typescript', options: { useBabel: false, tsLoader: { transpileOnly: true, experimentalWatchApi: true, }, forkTsChecker: { eslint: { files: ['*.js', '*.jsx', '*.ts', '*.tsx'], } }, }, }, ],};
选项
useBabel: boolean (默认值:false)
如果您想继续使用 babel
进行 JS/TS 互操作,或者您想对 typescript 文件应用任何 babel 转换(即:babel-plugin-styled-components
),请将 useBabel
设置为 true
。
tsLoader: TSLoaderOptions (默认值:{ transpileOnly: true, experimentalWatchApi: true })
使用此选项可覆盖 ts-loader
选项。在此处查看所有选项:ts-loader 选项。
forkTsChecker: TSCheckerOptions(默认值:{ async: 'compiler.options.mode === 'development'', typescript: true, eslint: undefined, issue: {}, formatter: 'codeframe', logger: { infrastructure: 'silent', issues: 'console', devServer: true } })
使用此项可覆盖 fork-ts-checker-webpack-plugin
选项。在此处查看所有选项:fork-ts-checker-webpack-plugin 选项。