Does anyone have experie…
Does anyone have experience with building an Next.js app in an Nx workspace?
I’m trying to serve some static files like images. The Next.js docs mention just putting a public
directory in the root and items in that directory will be available at /
. This works with nx serve, but when I run the prod build they are not bundled. Next docs are here https://nextjs.org/docs/basic-features/static-file-serving
Basic Features: Static File Serving | Next.js
Responses:
Full disclosuer, I’m not an expert in configuring Next, I could just be doing something wrong there
You probably need to add that directory to your assets in angular.json
or workspace.json
depending on if you use the Angular or Nx CLI.
yeah, I tried that actually. It doesn’t appear as though the nextjs builder supports assets as an option though
{
"$schema": "<http://json-schema.org/schema>",
"title": "Next Build",
"description": "Build a Next.js app",
"type": "object",
"properties": {
"root": {
"description": "The source root",
"type": "string"
},
"outputPath": {
"type": "string",
"description": "The output path of the generated files."
},
"fileReplacements": {
"description": "Replace files with other files in the build.",
"type": "array",
"items": {
"type": "object",
"properties": {
"replace": {
"type": "string"
},
"with": {
"type": "string"
}
},
"additionalProperties": false,
"required": ["replace", "with"]
},
"default": []
}
},
"required": []
}
this is the schema for that command