Migration
From a standalone project
Section titled “From a standalone project”-
Commit the project, so that you can compare afterwards.
-
Install and initialise the plugin in the workspace.
-
Terminal window nx g @geekvetica/nx-astro:import --source=../my-astro-blog --name=blog -
Do the steps the import leaves to you.
-
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.
From package.json scripts
Section titled “From package.json scripts”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.
-
Install and initialise the plugin.
-
Remove the scripts
dev,build,preview,checkandsyncfrom the project’spackage.json, or rename them. -
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',}); -
Check that the targets use the executors of the plugin, then build:
Terminal window nx show project legacynx build legacy
From run-commands targets
Section titled “From run-commands targets”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.
From plugin version 2 to 3
Section titled “From plugin version 2 to 3”- 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
.astrofiles are in the project graph. RemoveimplicitDependenciesthat only listed libraries imported there. - Sync. Remove
"cache": truefromsynctargets inproject.json: an older generator wrote it, and a cache hit generates nothing. - Options without effect.
astroVersionof the application generator,sourcemapandcleanofbuild, andrunoftestare deprecated. Remove them.