Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: vite only replace __dirname, __filename, import.meta.url in cjs #7161

Merged
merged 4 commits into from Mar 19, 2022
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion docs/config/index.md
Expand Up @@ -27,7 +27,9 @@ You can also explicitly specify a config file to use with the `--config` CLI opt
vite --config my-config.js
```

Note that Vite will replace `__filename`, `__dirname`, and `import.meta.url`. Using these as variable names will result in an error:
::: tip NOTE
Vite will only replace `__filename`, `__dirname`, and `import.meta.url` in **CommonJS context** and **TS config file** (whether there is `type: "module"` or not). Using these as variable names will result in an error:
:::
ydcjeff marked this conversation as resolved.
Show resolved Hide resolved

```js
const __filename = "value"
Expand Down