Skip to content

Migration

  1. Commit the project, so that you can compare afterwards.

  2. Install and initialise the plugin in the workspace.

  3. Import the project:

    Terminal window
    nx g @geekvetica/nx-astro:import --source=../my-astro-blog --name=blog
  4. Do the steps the import leaves to you.

  5. Build it:

    Terminal window
    nx build blog

Import several projects one after another. Their dependencies end up in one root package.json, so check that file for versions that have changed.

If an Astro project is already a package of the workspace, its scripts are targets that run the script. A script wins over the inferred target of the same name, so nx build still runs astro build without the cache settings of the plugin.

  1. Install and initialise the plugin.

  2. Remove the scripts dev, build, preview, check and sync from the project’s package.json, or rename them.

  3. Point the output to the place that Nx caches:

    apps/legacy/astro.config.mjs
    import { defineConfig } from 'astro/config';
    export default defineConfig({
    outDir: '../../dist/apps/legacy',
    });
  4. Check that the targets use the executors of the plugin, then build:

    Terminal window
    nx show project legacy
    nx build legacy

Targets in project.json win over inferred ones too. Delete those that call Astro, such as an nx:run-commands target with astro build, and set outDir as above. Keep targets with other names.

  • Nx 22 or newer is required. Update Nx first.
  • Astro 7 is supported since 3.0. Update Astro in the root package.json; the build copies the version to the apps.

Since 3.2 some workarounds are no longer needed:

  • Dependencies. Imports in .astro files are in the project graph. Remove implicitDependencies that only listed libraries imported there.
  • Sync. Remove "cache": true from sync targets in project.json: an older generator wrote it, and a cache hit generates nothing.
  • Options without effect. astroVersion of the application generator, sourcemap and clean of build, and run of test are deprecated. Remove them.
nx-astro 3.2.0 · MIT Developed by