-
Notifications
You must be signed in to change notification settings - Fork 301
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
chore: add astro to troubleshooting guide #3410
Merged
Merged
Changes from 6 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
348bd01
Update troubleshooting.react.mdx
reesscot 4327399
chore: further edits to troubleshooting
reesscot 8462c8d
chore: remove ts from vite sample file
reesscot e6d8377
Update docs/src/pages/[platform]/getting-started/troubleshooting/trou…
reesscot 334fc07
Update docs/src/pages/[platform]/getting-started/troubleshooting/trou…
reesscot 221bc0a
Update docs/src/pages/[platform]/getting-started/troubleshooting/trou…
reesscot 3d558aa
Update docs/src/pages/[platform]/getting-started/troubleshooting/trou…
reesscot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,13 +39,53 @@ Webpack 4 already includes this polyfill. | |
``` | ||
|
||
## Vite | ||
|
||
<Tabs> | ||
<TabItem title="TypeScript"> | ||
When working with a [Vite](https://vitejs.dev) project you must make a few modifications. Please follow the steps below. | ||
|
||
**1.** Add the following script tag to the `index.html` file at the bottom of the `<body>` tag. | ||
**1.** Add the following script tag to the `index.html` file right before the `</body>` tag. | ||
|
||
```html | ||
<script> | ||
window.global = window; | ||
window.process = { | ||
env: { DEBUG: undefined }, | ||
} | ||
var exports = {}; | ||
</script> | ||
</body> | ||
``` | ||
|
||
**2.** Update the `vite.config.ts` and add a resolve alias inside the `defineConfig({})` as seen below. | ||
|
||
```ts | ||
export default defineConfig({ | ||
plugins: [react()], | ||
resolve: { | ||
alias: [ | ||
{ | ||
find: './runtimeConfig', | ||
replacement: './runtimeConfig.browser', | ||
}, | ||
] | ||
} | ||
}) | ||
``` | ||
**3.** Update the `tsconfig.json` file and add `skipLibCheck: true` under `compilerOptions`. | ||
|
||
```json | ||
"compilerOptions": { | ||
"skipLibCheck": true, | ||
} | ||
... | ||
``` | ||
</TabItem> | ||
<TabItem title="JavaScript"> | ||
When working with a [Vite](https://vitejs.dev) project you must make a few modifications. Please follow the steps below. | ||
|
||
**1.** Add the following script tag to the `index.html` file right before the `</body>` tag. This will only run on the client side and will polyfill Node globals. | ||
|
||
```html | ||
<script> | ||
window.global = window; | ||
window.process = { | ||
|
@@ -56,10 +96,9 @@ When working with a [Vite](https://vitejs.dev) project you must make a few modif | |
</body> | ||
``` | ||
|
||
**2.** Update the `vite.config.ts` and add in a resolve object inside the `defineConfig({})` as seen below. | ||
**2.** Update the `vite.config.js` and add a resolve alias inside the `defineConfig({})` as seen below. | ||
|
||
```js | ||
... | ||
export default defineConfig({ | ||
plugins: [react()], | ||
resolve: { | ||
|
@@ -72,7 +111,41 @@ export default defineConfig({ | |
} | ||
}) | ||
``` | ||
</TabItem> | ||
</Tabs> | ||
|
||
## Astro | ||
|
||
When working with a [Astro](https://astro.build/) project you must make a few modifications. Please follow the steps below. | ||
<Tabs> | ||
<TabItem title="TypeScript"> | ||
**1.** Add the following script to the bottom of the `index.astro` file. This will only run on the client side and will polyfill Node globals. | ||
|
||
```html | ||
<script> | ||
window.global = window; | ||
window.process = { | ||
env: { DEBUG: undefined }, | ||
} as unknown as NodeJS.Process; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. note: all astro files are TS files |
||
var exports = {}; | ||
</script> | ||
``` | ||
|
||
**2.** Update the `astro.config.mjs` to add a resolve object inside the `defineConfig({})` as seen below. | ||
|
||
```js | ||
export default defineConfig({ | ||
plugins: [react()], | ||
resolve: { | ||
alias: [ | ||
{ | ||
find: './runtimeConfig', | ||
replacement: './runtimeConfig.browser', | ||
}, | ||
] | ||
} | ||
}) | ||
``` | ||
**3.** Update the `tsconfig.json` file and add `skipLibCheck: true` under `compilerOptions`. | ||
|
||
```js | ||
|
@@ -81,6 +154,38 @@ export default defineConfig({ | |
"skipLibCheck": true, | ||
... | ||
``` | ||
</TabItem> | ||
<TabItem title="JavaScript"> | ||
**1.** Add the following script to the bottom of the `index.astro` file. This will only run on the client side and will polyfill Node globals. | ||
|
||
```html | ||
<script> | ||
window.global = window; | ||
window.process = { | ||
env: { DEBUG: undefined }, | ||
} | ||
var exports = {}; | ||
</script> | ||
``` | ||
|
||
**2.** Update the `astro.config.mjs` to add in a resolve object inside the `defineConfig({})` as seen below. | ||
reesscot marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
```js | ||
export default defineConfig({ | ||
plugins: [react()], | ||
resolve: { | ||
alias: [ | ||
{ | ||
find: './runtimeConfig', | ||
replacement: './runtimeConfig.browser', | ||
}, | ||
] | ||
} | ||
}) | ||
``` | ||
</TabItem> | ||
</Tabs> | ||
|
||
|
||
## Create React App | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Much more explicit!