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/more concise version of custom imports using NODE_OPTIONS #182

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
],
"scripts": {
"clean": "rimraf public .greenwood storybook-static",
"build": "node --import @greenwood/cli/register ./node_modules/@greenwood/cli/src/index.js build",
"build": "NODE_OPTIONS='--import @greenwood/cli/register' greenwood build",
"dev": "greenwood develop",
"serve": "npm run clean && npm run build && greenwood serve",
"story:dev": "storybook dev -p 6006",
Expand Down
22 changes: 20 additions & 2 deletions src/pages/docs/pages/server-rendering.md
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ For request handling, Greenwood will pass a native `Request` object and a Greenw

## Custom Imports

To use custom imports (non JavaScript resources) on the server side for prerendering or SSR use cases, you will need to invoke Greenwood using **NodeJS** from the CLI and pass the `--imports` flag along with the path to Greenwood's provided register function. _**This feature requires NodeJS version `>=21.10.0`**_.
To use custom imports (non JavaScript resources) on the server side for prerendering or SSR use cases, you will need to invoke Greenwood using **NodeJS** from the CLI and pass the [`--import` flag](https://nodejs.org/api/module.html#enabling) to NodeJS along with the path to Greenwood's provided register function. _**This feature requires NodeJS version `>=21.10.0`**_.

<!-- prettier-ignore-start -->

Expand All @@ -328,7 +328,25 @@ Or most commonly as an npm script in your _package.json_
"build": "node --import @greenwood/cli/register ./node_modules/@greenwood/cli/src/index.js build"
}
}
```
```

</app-ctc-block>

<!-- prettier-ignore-end -->

Alternatively, you can pass `--import` as a `NODE_OPTION`, which doesn't require having to specify the full path to the Greenwood CLI in your _node_modules_.

<!-- prettier-ignore-start -->

<app-ctc-block variant="snippet" heading="package.json">

```json
{
"scripts": {
"build": "NODE_OPTIONS='--import @greenwood/cli/register' greenwood build"
}
}
```

</app-ctc-block>

Expand Down