Skip to content

Commit b946d96

Browse files
Copilotntotten
andcommitted
Add documentation for prettierExecutable feature
Co-authored-by: ntotten <282782+ntotten@users.noreply.github.com>
1 parent 3399ded commit b946d96

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

README.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,22 @@ This extension bundles Prettier 3.x by default. If your project has a local inst
138138

139139
This extension supports [Prettier plugins](https://prettier.io/docs/en/plugins.html) when you are using a locally or globally resolved version of prettier. If you have Prettier and a plugin registered in your `package.json`, this extension will attempt to register the language and provide automatic code formatting for the built-in and plugin languages.
140140

141+
### Docker and Custom Environments
142+
143+
If you use Docker or other containerized development environments, you can configure the extension to run Prettier inside the container using the [`prettier.prettierExecutable`](#prettierprettierexecutable) setting. This allows you to use the specific version of Prettier and its dependencies that are installed in your container.
144+
145+
Example configuration for Docker Compose:
146+
147+
```json
148+
{
149+
"prettier.prettierExecutable": ["docker", "compose", "exec", "-T", "app", "node_modules/.bin/prettier"]
150+
}
151+
```
152+
153+
**Note:** The `-T` flag for `docker compose exec` disables pseudo-TTY allocation, which is required for stdin/stdout handling.
154+
155+
Alternatively, consider using [VS Code Dev Containers](https://code.visualstudio.com/docs/devcontainers/containers) to develop directly inside the Docker container, which allows the extension to work normally with the containerized Prettier installation.
156+
141157
## Configuration
142158

143159
There are multiple options for configuring Prettier with this extension. You can use [VS Code settings](#prettier-settings), [prettier configuration files](https://prettier.io/docs/en/configuration.html), or an `.editorconfig` file. The VS Code settings are meant to be used as a fallback and are generally intended only for use on non-project files. **It is recommended that you always include a prettier configuration file in your project specifying all settings for your project.** This will ensure that no matter how you run prettier - from this extension, from the CLI, or from another IDE with Prettier, the same settings will get applied.
@@ -285,6 +301,32 @@ Supply a custom path to the prettier module. This path should be to the module f
285301

286302
**Disabled on untrusted workspaces**
287303

304+
#### prettier.prettierExecutable
305+
306+
Supply an external executable to run Prettier instead of loading it as a module. This is useful for scenarios like Docker where Prettier needs to run in a different environment.
307+
308+
The value should be an array where the first element is the executable path and subsequent elements are arguments. For example:
309+
310+
```json
311+
{
312+
"prettier.prettierExecutable": ["docker", "compose", "exec", "app", "node_modules/.bin/prettier"]
313+
}
314+
```
315+
316+
Or for a simple wrapper script:
317+
318+
```json
319+
{
320+
"prettier.prettierExecutable": ["node", "scripts/prettier-wrapper.js"]
321+
}
322+
```
323+
324+
When this setting is configured, it takes precedence over `prettier.prettierPath` and module resolution.
325+
326+
**Note:** The executable must support standard Prettier CLI options (e.g., `--parser`, `--stdin-filepath`, etc.) and must accept input via stdin.
327+
328+
**Disabled on untrusted workspaces**
329+
288330
#### prettier.resolveGlobalModules (default: `false`)
289331

290332
When enabled, this extension will attempt to use global npm or yarn modules if local modules cannot be resolved.

0 commit comments

Comments
 (0)