Skip to content

Commit f065de9

Browse files
docs/more concise version of custom imports using NODE_OPTIONS (#182)
1 parent 6be31fa commit f065de9

2 files changed

Lines changed: 21 additions & 3 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
],
1414
"scripts": {
1515
"clean": "rimraf public .greenwood storybook-static",
16-
"build": "node --import @greenwood/cli/register ./node_modules/@greenwood/cli/src/index.js build",
16+
"build": "NODE_OPTIONS='--import @greenwood/cli/register' greenwood build",
1717
"dev": "greenwood develop",
1818
"serve": "npm run clean && npm run build && greenwood serve",
1919
"story:dev": "storybook dev -p 6006",

src/pages/docs/pages/server-rendering.md

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ For request handling, Greenwood will pass a native `Request` object and a Greenw
305305

306306
## Custom Imports
307307

308-
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`**_.
308+
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`**_.
309309

310310
<!-- prettier-ignore-start -->
311311

@@ -331,7 +331,25 @@ Or most commonly as an npm script in your _package.json_
331331
"build": "node --import @greenwood/cli/register ./node_modules/@greenwood/cli/src/index.js build"
332332
}
333333
}
334-
```
334+
```
335+
336+
</app-ctc-block>
337+
338+
<!-- prettier-ignore-end -->
339+
340+
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_.
341+
342+
<!-- prettier-ignore-start -->
343+
344+
<app-ctc-block variant="snippet" heading="package.json">
345+
346+
```json
347+
{
348+
"scripts": {
349+
"build": "NODE_OPTIONS='--import @greenwood/cli/register' greenwood build"
350+
}
351+
}
352+
```
335353

336354
</app-ctc-block>
337355

0 commit comments

Comments
 (0)