nxext / nx-extensions

Nx Extensions for Stencil, Svelte, SolidJS, Preact, Ionic, and Capacitor
MIT License
465 stars 102 forks source link

Stencil: `@nxext/stencil:build` fails if the `prerender` option is enabled in project.json #833

Open dgonzalezr opened 1 year ago

dgonzalezr commented 1 year ago

Describe the bug

Enabling the prerender option in the target build makes the @nxext/stencil:build fail.

image

To Reproduce

  1. Create an Nx workspace: npx create-nx-workspace@latest myorg --preset=ts
  2. Make sure to downgrade to Nx version 14.x since nxext/stencil is not yet compatible with Nx v15:
    "devDependencies": {
    "@nrwl/cli": "14.8.6",
    "@nrwl/js": "14.8.6",
    "@nrwl/workspace": "14.8.6",
    "nx": "14.8.6",
    "prettier": "^2.7.1",
    "typescript": "~4.8.4"
    }
  3. Add @nxext/stencil: npm i -D @nxext/stencil
  4. Generate a Stencil library: nx g @nxext/stencil:lib components --buildable --publishable
  5. Add the prerender option to the build target
    "build": {
    "executor": "@nxext/stencil:build",
    "outputs": ["{options.outputPath}"],
    "options": {
    "projectType": "library",
    "tsConfig": "libs/components/tsconfig.lib.json",
    "configPath": "libs/components/stencil.config.ts",
    "outputPath": "dist/components",
    "prerender": true
    },
    ...

Expected behavior

The prerender option work as expected in the same way as you would do in a standalone Stencil library component within the --prerender CLI flag

DominikPieper commented 1 year ago

With prerender you need to set the url: baseUrl: ’https://.local/', for the www task

baseUrl: 'https://.local/',

Unfortunately the error you got is the generic error I get from the stencil compiler without the log entries ^^'