Skip to content

Commit

Permalink
docs/more concise version of custom imports using NODE_OPTIONS (#182)
Browse files Browse the repository at this point in the history
  • Loading branch information
thescientist13 authored Feb 15, 2025
1 parent 6be31fa commit f065de9
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
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 @@ -305,7 +305,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 @@ -331,7 +331,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

0 comments on commit f065de9

Please sign in to comment.