Can*_*mus 8 javascript configuration node.js reactjs webpack
最近,我一直在创建一个 chrome 扩展,为此,我使用了一堆需要配置文件的工具和捆绑器 - 通常以点开头。在根目录中,一切看起来都那么混乱,我花了几秒钟才在根目录中找到一个文件。
-----
|__ src/
|__ static/
|__ .prettierc
|__ .prettierignore
|__ .gitignore
|__ .parcelrc
|__ README.md
|__ manifest.json
|__ popup.html
Run Code Online (Sandbox Code Playgroud)
我想要做的是将每个配置文件放入config/
我在此处显示的命名目录中。
-----
|__ src/
|__ static/
|-- config/
| |__ .prettierc
| |__ .prettierignore
| |__ .gitignore
| |__ .parcelrc
|
|__ README.md
|__ manifest.json
|__ popup.html
Run Code Online (Sandbox Code Playgroud)
如何在不破坏正常功能的情况下实现这一目标?谢谢!
我知道有些工具可以让您在任何地方定义配置文件。然而,其中一些是严格的,你甚至不能重命名它们。我查找了我使用的工具,但找不到有关此问题的任何信息。
1.使用IDE设置隐藏配置文件
我建议您将它们保留在默认位置,因为这是常见的做法。相反,您可以隐藏它们,这就是我大部分时间为保持项目结构整洁所做的事情。
如果您使用 VS Code,您可以添加.vscode/settings.json
并隐藏您不想在资源管理器选项卡中看到的文件。当您需要检查或编辑任何内容时,可以将它们切换回来。
.vscode/settings.json
您的案例的文件内容:
{
"files.exclude": {
".prettierrc": true,
".prettierignore": true,
".gitignore": true,
".parcelrc": true
}
}
Run Code Online (Sandbox Code Playgroud)
同样,如果您使用 JetBrains IDE,请转至File > Settings > Editor > File Types > Ignore files and folders
并附加要隐藏的文件列表。您的导航器将会更加干净。
2.使用VS Code扩展来嵌套文件
settings.json
文件中:{
// keep other settings as they are, and add the following at the bottom:
"explorer.experimental.fileNesting.patterns": {
"configs": ".gitignore, .prettierrc, .prettierignore, .parcelrc"
}
}
Run Code Online (Sandbox Code Playgroud)
configs
在项目根目录中命名的空文件。3. 向您运行的命令添加标志以使用不同的配置文件路径
如果您仍然想更改他们的位置,这可能对您有帮助。
运行prettier
命令时,添加以下标志:
prettier --config [.prettierrc path] --ignore-path [.prettierignore path]
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
2474 次 |
最近记录: |