Development
- New Nuxt Framework - Initialise
- New Nuxt Framework - Cloning existing project
- Nuxt Framework - Server Setup
New Nuxt Framework - Initialise
Make sure pnpm is installed through homebrew
PHPStorm -> New empty project
Terminal
pnpm create nuxt
-> follow steps (when it asks which package manager, select pnpm)
When asked which modules, nuxt/eslint, nuxt/icon, nuxt/image
Once project is created, run pnpm approve-builds
, select all if there is any.
To start dev server, run pnpm run dev
New Nuxt Framework - Cloning existing project
Clone project like normal, navigate to true project directory (where package.json exists), and run pnpm install
Once all packages have installed, run pnpm run dev
to launch the development server
Nuxt Framework - Server Setup
Ensure pm2 and latest nodejs are both installed on the server.
Create a ecosystem.config.cjs file in the project root, and it should look like this:
module.exports = {
apps: [
{
name: 'Site-Name',
port: '3000',
exec_mode: 'cluster',
instances: 'max',
script: './.output/server/index.mjs'
}
]
}
Change site name and port so they don't clash
Navigate to the project root, then runpnpm install
pm2 start ecosystem.config.cjs
You should see the output from pm2, now create a file called build.sh containing this:
Replace the necessary details.
cd elsenham-roofing-reclaim/
git pull
pnpm i
pnpm build
pm2 restart Elsenham-Roofing
echo "✅😊 build complete - elsenham"
In Nginx on the server, it should forward all requests to localhost:{specified_port} as each Nuxt app runs it's own Nitro server, a compiled version of the project that runs a lot quicker.