有没有办法将每个配置文件放在config Directory中,而不是root Node Project中?
最近,我一直在创建一个 chrome 扩展,为此,我使用了一堆需要配置文件的工具和捆绑器 - 通常以点开头。在根目录中,一切看起来都那么混乱,我花了几秒钟才在根目录中找到一个文件。
-----
|__ src/
|__ static/
|__ .prettierc
|__ .prettierignore
|__ .gitignore
|__ .parcelrc
|__ README.md
|__ manifest.json
|__ popup.html
我想要做的是将每个配置文件放入名为 config/
的目录中,如我在此处所示。
-----
|__ src/
|__ static/
|-- config/
| |__ .prettierc
| |__ .prettierignore
| |__ .gitignore
| |__ .parcelrc
|
|__ README.md
|__ manifest.json
|__ popup.html
如何在不破坏正常功能的情况下实现这一目标?谢谢!
我知道有些工具可以让您在任何地方定义配置文件。然而,其中一些是严格的,你甚至不能重命名它们。我查找了我使用的工具,但找不到有关此问题的任何信息。
Lately, I've been creating a chrome extension and for that, I use a bunch of tools and bundlers that requires a config file-usually starting with a dot. In the root directory, everything looks so cluttered, and it takes a few seconds for me to find a file in the root.
-----
|__ src/
|__ static/
|__ .prettierc
|__ .prettierignore
|__ .gitignore
|__ .parcelrc
|__ README.md
|__ manifest.json
|__ popup.html
What I want to do is to put every config file into a directory named config/
as I show here.
-----
|__ src/
|__ static/
|-- config/
| |__ .prettierc
| |__ .prettierignore
| |__ .gitignore
| |__ .parcelrc
|
|__ README.md
|__ manifest.json
|__ popup.html
How can I achieve this without breaking the normal functionality? Thanks!
I know that some tools lets you define your config file anywhere you want. However, some of them are strict and you can't even rename them. I looked up for the tools I used but I cannot find any information about this issue.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
1。使用IDE设置隐藏配置文件
我建议您将其保留在其默认位置,因为这是这样做的常见约定。取而代之的是,您可以隐藏它们,这是我在大多数时候要保持项目结构清洁的操作。
如果使用VS代码,则可以添加
.vscode/settings.json
,然后隐藏您不想在Explorer选项卡中看到的文件。您可以在需要检查或编辑任何内容时将其重新切换。.vscode/settings.json
您的情况的文件内容:同样,如果您使用JetBrains IDES,请转到
file>设置>编辑>文件类型>忽略文件和文件夹
,并附加要隐藏的文件列表。您的导航器会更干净。2。使用VS代码扩展名nest Files
settings.json
file:configs
的空文件您的项目。最后,您必须拥有类似的东西,这可能是您要寻找的东西:
3。将标志添加到您运行的命令中,以使用配置文件的其他路径
如果您仍然想更改其位置,这可能对您有所帮助。.
运行
Prettier
命令时,添加以下内容标志:1. Use IDE settings to hide config files
I recommend that you keep them in their default location since it is a common conventation to do so. Instead, you can just hide them and this is what I do most of the time to keep my project structure clean.
If you use VS Code, you can add a
.vscode/settings.json
and hide the files you don't want to see in the explorer tab. You can toggle them back when you need to check or edit any..vscode/settings.json
file content for your case:Similarly, if you use JetBrains IDEs, go to
File > Settings > Editor > File Types > Ignore files and folders
and append the list of files that you want to hide. Your navigator will be much cleaner.2. Use a VS Code extension to nest files
settings.json
file:configs
in the root of your project.Finally, you must have something like this which is probably what you are looking for:
3. Add flags to commands you run to use a different path for config files
If you still want to change their location, this might be helpful for you..
When running
prettier
command, add the following flags: