I build a multi-site where one frontend can request information from the backend based on the domain. Code and style is always the same and some routes too, but content must be dynamic per domain.
Everything works fine otherwise, but I don't know how to run Nuxt so that CSS / Tailwind / JavaScript is in production mode and SSR + CSR will handle whatever comes from the backend. Normal pages can't be static pages and I don't know all routes needed so those need to be generated when the backend sends data.
I tried to follow Nuxt server tutorials, but no luck yet. I think I have to run Express or module nuxt-start, but those gave FATAL No build files found in .nuxt/dist/server.
How can one run Nuxt which can handle multiple domains and different content? npm run dev works as I want for production working, but needs to be more optimized and faster. What kind of configuration I need?
To build for production, you need to either do:
yarn generate (target: static)yarn build (target: server, aka the default value)yarn start (on the production server).As for having custom content, this one should probably be dependent of some env variables to decide where to fetch the content from, and then using nuxtServerInit to populate your Vuex store: https://nuxtjs.org/docs/2.x/concepts/nuxt-lifecycle
Of course, you could also do it elsewhere, like in serverMiddleware or at build time if you use Docker.
As for the routes, you can keep them dynamic and populate them with the related data.