scullyio / scully

The Static Site Generator for Angular apps
https://scully.io/
MIT License
2.55k stars 256 forks source link

Scully fail to make pages - plugin "storeRoutes has thrown the below error, #1630

Open boskiv opened 1 year ago

boskiv commented 1 year ago

🐞 Bug report

Description

🔬 Minimal Reproduction

💻Your Environment

Angular Version:


➜  git:(master) ✗ nx --version
15.3.0

Scully Version:


"@scullyio/ng-lib": "^2.1.41",
"@scullyio/scully": "^2.1.41",
"@scullyio/scully-plugin-puppeteer": "^2.1.41",

🔥 Exception or Error


➜  git:(master) ✗ npx scully --pr docs --scanRoutes
  ⚠ Folder "./scully" doesn't seem to contain custom plugins
  x Could not find project "docs" in 'angular.json'.
  ✔ new Angular build files imported
  ✔ Starting servers for project "docs"
  ✔ Started Scully static server on "http://localhost:1668/"
  ✔ Started Angular distribution server on "http://localhost:1864/" 
  ✔ Scully Development Server is up and running
  ✔ Puppeteer is being launched
  ✔ Successfully scanned Angular app for routes
  ✔ Successfully added routes created from routePlugins
  x  The scullySystem plugin "storeRoutes has thrown the below error,
              while trying to render route "unknown"
              Scully will exit
  x TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined
                                               %                                                                                                                                                               ➜  


import { ScullyConfig } from '@scullyio/scully';
import '@scullyio/scully-plugin-puppeteer';

const defaultPostRenderers = ['seoHrefOptimise'];

export const config: ScullyConfig = {
  projectRoot: './apps/docs/src',
  projectName: 'docs',
  distFolder: './dist/apps/docs',
  outDir: './dist/docs-static',
  routes: {},
  defaultPostRenderers,
  target: 'targets',
  puppeteerLaunchOptions: {
    args: ['--no-sandbox'],
  },
};
djmcgrath101 commented 1 year ago

Also experiencing this same issue on Nx version 15.4.5

maximegris commented 1 year ago

@boskiv @djmcgrath101 I managed to make the script working by adding the key sourceRoot with the same value as projectRoot in my scully config file. (My project is with Nx : 15.6.3)

This is what just showed me the way

storeRoutes.ts line 16

const srcFile = join(scullyConfig.homeFolder, scullyConfig.sourceRoot, routesFileName); // wrong path generated when sourceRoot is not set
spaceribs commented 1 year ago

@maximegris this worked for me as well 👍 thank you!

FanYeeChok commented 1 year ago

storeRoutes.ts

@boskiv @djmcgrath101 I managed to make the script working by adding the key sourceRoot with the same value as projectRoot in the scully config file. (My project is with Nx : 15.6.3)

storeRoutes.ts line 16

const srcFile = join(scullyConfig.homeFolder, scullyConfig.sourceRoot, routesFileName); // wrong path generated when sourceRoot is not set

hi @maximegris , may i know where is storeRoutes.ts ?

maximegris commented 1 year ago

Hi @FanYeeChok

The file is here

FanYeeChok commented 1 year ago

I see, that means modify existing scully code? anyway, i tot you mention sourceRoot, so i add the sourceRoot at scully.web-showroom.config.ts and its working fine.

e.g.

export const config: ScullyConfig = {
  projectRoot: "./apps/web-showroom/src",
  projectName: "web-showroom",
  distFolder: './dist/apps/web-showroom',
  sourceRoot: "./apps/web-showroom/src",
  spsModulePath: 'YOUR OWN MODULE PATH HERE',
  outDir: './dist/static',
  defaultPostRenderers: [Http404Plugin,'seoHrefOptimise', baseHrefRewrite],
  target: 'targets',
  // handle404: ['', 'index', 'baseOnly', '404', 'none'],
  handle404: 'index',
  routes: {
  }
};
maximegris commented 1 year ago

@FanYeeChok Yes it was by adding sourceRoot in your own Scully config, not by modifying the Scully code :)