Skip to content

Commit

Permalink
docs: vite only replace __dirname, __filename, import.meta.url
Browse files Browse the repository at this point in the history
…in cjs (#7161)

Co-authored-by: Bjorn Lu <bjornlu.dev@gmail.com>
  • Loading branch information
ydcjeff and bluwy committed Mar 19, 2022
1 parent 0646fe8 commit f448593
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion docs/config/index.md
Expand Up @@ -27,14 +27,17 @@ 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 replace `__filename`, `__dirname`, and `import.meta.url` in **CommonJS** and **TypeScript** config files. Using these as variable names will result in an error:

```js
const __filename = "value"
// will be transformed to
const "path/vite.config.js" = "value"
```

:::

### Config Intellisense

Since Vite ships with TypeScript typings, you can leverage your IDE's intellisense with jsdoc type hints:
Expand Down

0 comments on commit f448593

Please sign in to comment.