Nuxt
Nuxt is a frontend framework based on Vue.JS.
This document explains how to use it in conjunction with FoalTS.
Installation
Create your frontend and backend projects in two different folders.
foal createapp backend
npx create-nuxt-app frontend
Set Up
-
Open the file
nuxt.config.js
in thefrontend/
directory, move it to yourbackend/
directory and update its first lines as follows:module.exports = {
srcDir: '../frontend',
// ...
} -
Go to your server directory and install
nuxt
.npm install nuxt
-
Then update your
src/index.ts
file as follows:import { loadNuxt, build } from 'nuxt';
// ...
async function main() {
const isDev = process.env.NODE_ENV !== 'production';
// We get Nuxt instance
const nuxt = await loadNuxt(isDev ? 'dev' : 'start');
if (isDev) {
build(nuxt)
}
// ...
const app = await createApp(AppController, {
postMiddlewares: [
nuxt.render
]
});
// ...
}
main(); -
Finally, delete the file
index.html
inbackend/public
.