-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
i18n(ja): Update configuring-astro.md #2137
i18n(ja): Update configuring-astro.md #2137
Conversation
✅ Deploy Preview for astro-docs-2 ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify site settings. |
## 出力するファイル名のカスタマイズ | ||
|
||
インポートしたJavaScriptやCSSファイルなど、Astroが処理するコードについては、`astro.config.*`ファイルの`vite.build.rollupOptions`で[`entryFileNames`](https://rollupjs.org/guide/en/#outputentryfilenames)、[`chunkFileNames`](https://rollupjs.org/guide/en/#outputchunkfilenames)、[`assetFileNames`](https://rollupjs.org/guide/en/#outputassetfilenames)を用いて出力するファイル名をカスタマイズできます。 | ||
|
||
```js ins={9-11} | ||
// astro.config.mjs | ||
import { defineConfig } from 'astro/config' | ||
|
||
export default defineConfig({ | ||
vite: { | ||
build: { | ||
rollupOptions: { | ||
output: { | ||
entryFileNames: 'entry.[hash].js', | ||
chunkFileNames: 'chunks/chunk.[hash].js', | ||
assetFileNames: 'assets/asset.[hash][extname]', | ||
}, | ||
}, | ||
}, | ||
}, | ||
}) | ||
``` | ||
|
||
これは、広告ブロッカーの影響を受ける可能性のある名前のスクリプト(たとえば`ads.js`や`google-tag-manager.js`)がある場合に役に立ちます。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#931 にて追加されたセクションです。
@@ -24,14 +24,14 @@ export default defineConfig({ | |||
|
|||
`defineConfig()`を使うと、IDEで自動的にタイプヒントを表示できるのでおすすめですが、これはオプションです。最低限必要で、有効な設定ファイルは次のようなものです。 | |||
|
|||
```js | |||
```js title="astro.config.mjs" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
この行やこれ以下で登場する、ファイル名を指定するタイプの修正は #1135 にておこなわれています。
// astro.config.mjs | ||
import { defineConfig } from 'astro/config' | ||
|
||
export default defineConfig({ | ||
// 現在の作業ディレクトリにある "./foo"ディレクトリを指します。 | ||
root: 'foo' | ||
// 現在の作業ディレクトリにある "./foo"ディレクトリを指します。 | ||
root: 'foo' | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
defineConfig
のインポートとインデントの修正も #1135 にておこなわれたものです。
```js | ||
```js "import.meta.url" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#1175 に対応しています。
Astroは、JavaScriptの設定ファイルとして、次のようないくつかのファイル形式をサポートしています。 `astro.config.js`,`astro.config.mjs`,`astro.config.cjs`,`astro.config.ts` | ||
Astroは、JavaScriptの設定ファイルとして、`astro.config.js`、`astro.config.mjs`、`astro.config.cjs`、`astro.config.ts`という複数のファイル形式をサポートしています。多くの場合は`.mjs`を、設定ファイルをTypeScriptで記述する場合は`.ts`を使用することをおすすめします。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#1514 にて "We recommend using .mjs
in most cases or .ts
if you want to write TypeScript in your config file." という文が追加されたため、対応する訳文を追加しました。
また、もとの訳文で "astro.config.js,astro.config.mjs,astro.config.cjs,astro.config.ts" という部分が英語のカンマのままであったり、直前の文と接続していないように思えたため、なるべく自然な日本語となるように修正してみました。
:::note | ||
`import.meta.env`や`import.meta.glob`など、Vite固有の`import.meta`プロパティは設定ファイルからはアクセスできません。こうしたユースケースについては[dotenv](https://github.com/motdotla/dotenv)や[fast-glob](https://github.com/mrmlnc/fast-glob)などの代替手段をおすすめします。 | ||
::: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#1967 にて追加されました。
`root`または`--root`フラグで相対パスを指定すると、`astro`コマンドを実行した現在の作業ディレクトリに反して、指定した相対パスをルートとして使用します。 | ||
`root`または`--root`フラグで相対パスを指定すると、`astro`コマンドを実行した現在の作業ディレクトリを起点として、指定した相対パスを解決します。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
この一文なのですが、原文は
If you provide a relative path to root or the --root CLI flag, Astro will resolve it against the current working directory where you ran the astro CLI command.
となっており、「root で指定された内容 (= it)」を「コマンドを実行した現在の作業ディレクトリに対して (= against the current working directory)」見つけ出すということになると思うのですが、もとの訳文の「反して」だと少し意味が違うように思えたため、「対して」をよりわかりやすくした「起点として」に修正しました。
また、上のように修正した場合、resolve に対応する訳が「ルートとして使用」のままではおかしくなってしまうため、原文に忠実に「解決」という言葉を用いるように変更しています(「名前解決」などの言葉はこの業界では一般的であると思われるため、このように変えても読みづらくはならないと判断しました)。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@morinokami 全体を現在の英語版と比較し、また、個別にコメントいただいた内容についても、すべて確認しました。丁寧に修正されていて、またもとの訳文を改善していただいた箇所も素晴らしかったです。LGTM。
What kind of changes does this PR include?
Description