简体   繁体   English

将tsconfig.json放置在Symfony Encore中以定义TypeScript配置?

[英]Where to place tsconfig.json in Symfony Encore to define TypeScript config?

Symfony Encore now supports using TypeScript by default ( Add support to enableTypescriptLoader ), and it works great. Symfony Encore现在默认支持使用TypeScript( 添加对enableTypescriptLoader的支持 ),并且效果很好。 However, I would like to configure my TypeScript configuration using a tsconfig.json file. 但是,我想使用tsconfig.json文件配置TypeScript配置。

I tried figuring out where to place this, but I got lost in the rabbithole and didn't figure out where I should place the file for ts-loader to pick it up. 我试图弄清楚该放在哪里,但迷路了,没有弄清楚应该将文件放置在哪里供ts-loader拾取。 Or if there is a configuration that enables this. 或者是否有启用此功能的配置。

Having the tsconfig.json in same place of webpack.config.js should do the job. 具有tsconfig.json在同一个地方的webpack.config.js应该做的工作。

ts-loader assumes the same as default configuration. ts-loader假定与默认配置相同。

Check ts-loader configuration documentation, there is one option for configuring file name in case it is located somewhere else. 查看ts-loader配置文档,如果文件名位于其他位置,则有一个配置文件名的选项。

UPDATE: Keep an eye on this docs there is some documentation on the way. 更新:密切关注此文档 ,途中有一些文档

Configuration goes like: 配置如下:

.enableTypeScriptLoader(function (typeScriptConfigOptions) {
    typeScriptConfigOptions.transpileOnly = true;
    typeScriptConfigOptions.configFileName = '/path/to/tsconfig.json';
});

But again, loader defaults for configFileName option is: tsconfig.json so, should be enough having the file in same directory of webpack.config.js or in same directory from where you run webpack, not sure now actually. 但同样,loader的configFileName选项默认为: tsconfig.json因此,将文件放在webpack.config.js同一目录中或运行webpack的目录中应该足够了,现在不确定。 I always run webpack from same dir as webpack.config.js :) 我总是从与webpack.config.js相同的目录运行webpack.config.js :)

Cheers 干杯

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 为什么 Vite 会创建两个 TypeScript 配置文件:tsconfig.json 和 tsconfig.node.json? - Why does Vite create two TypeScript config files: tsconfig.json and tsconfig.node.json? tsconfig.json:在配置文件中找不到输入? - tsconfig.json: not input were found in config file? TypeScript编译器忽略tsconfig.json中的声明文件 - TypeScript compiler ignores declaration file in tsconfig.json tsconfig.json 的编译器选项它们从何而来? - tsconfig.json 's compiler options where do they come from? 为什么打字稿编译器会在服务器启动时更改我的 tsconfig.json 文件? - Why is typescript compiler changing my tsconfig.json file on server start up? Typescript 编译器在 tsconfig.json 上包含文件时找不到绝对路径 - Typescript compiler not finding absolute paths when including files on tsconfig.json TypeScript。 在 tsconfig.json 中使用 ESNext 作为目标时如何防止转译? - TypeScript. How prevent transpiling while using ESNext as a target in tsconfig.json? 为什么普通的 json 文件不允许评论,而 tsconfig.json 允许评论? - Why normal json files don't allow comments where as tsconfig.json allow comment? 在没有 tsconfig.json 全局项目级别的情况下,打字稿文件在 vs2017 中自动创建 Javascript - Typescript file auto create Javascript in vs2017 without tsconfig.json globally project level TypeScript tsconfig.json文件中使用typeRoots与baseUrl的相对路径 - relative path using typeRoots vs. baseUrl in TypeScript tsconfig.json file
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM