Skip to content

Commit 202a0d3

Browse files
authored
docs: add import.meta.env.DEV example (#2163)
1 parent adfdf6d commit 202a0d3

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

guide/env-and-mode.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,17 @@
22

33
Vite は特定の定数を特別な `import.meta.env` オブジェクトの下で公開します。この定数は開発中はグローバル変数として定義され、ビルド時にはツリーシェイキングを効果的に行うために静的に置き換えられます。
44

5+
:::details 例
6+
7+
```js
8+
if (import.meta.env.DEV) {
9+
// この中のコードは本番ビルドでツリーシェイキングされます
10+
console.log('Dev mode')
11+
}
12+
```
13+
14+
:::
15+
516
## ビルトイン定数
617
718
いくつかのビルトイン定数は全てのケースで利用可能です:

0 commit comments

Comments
 (0)