For detailed explanation on how things work, check out the documentation or bellow :
Details
You can create the following extra directories, some of which have special behaviors. Only pages
is required; you can delete them if you don't want to use their functionality.
The assets directory contains your uncompiled assets such as Stylus or Sass files, images, or fonts.
More information about the usage of this directory in the documentation.
The components directory contains your Vue.js components. Components make up the different parts of your page and can be reused and imported into your pages, layouts and even other components.
More information about the usage of this directory in the documentation.
Layouts are a great help when you want to change the look and feel of your Nuxt app, whether you want to include a sidebar or have distinct layouts for mobile and desktop.
More information about the usage of this directory in the documentation.
This directory contains your application views and routes. Nuxt will read all the *.vue
files inside this directory and setup Vue Router automatically.
More information about the usage of this directory in the documentation.
The plugins directory contains JavaScript plugins that you want to run before instantiating the root Vue.js Application. This is the place to add Vue plugins and to inject functions or constants. Every time you need to use Vue.use()
, you should create a file in plugins/
and add its path to plugins in nuxt.config.js
.
More information about the usage of this directory in the documentation.
This directory contains your static files. Each file inside this directory is mapped to /
.
Example: /static/robots.txt
is mapped as /robots.txt
.
More information about the usage of this directory in the documentation.
This directory contains your Vuex Store files. Vuex Store option is implemented in the Nuxt.js framework.
Creating a file in this directory automatically activates the option in the framework.
More information about the usage of this directory in the documentation.
sudo nano /etc/nginx/sites-available/my_project
And add :
server {
listen 80;
listen [::]:80;
index index.html;
server_name IP_ADRESS_OR_DOMAIN_NAME;
access_log /home/eljovial/nuxt/my_project/logs/access.log;
error_log /home/eljovial/nuxt/my_project/logs/error.log error;
location / {
proxy_pass http://localhost:PORT_NUMBER;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
sudo ln -s /etc/nginx/sites-available/my_project /etc/nginx/sites-enabled
sudo nginx -t
Don't forget to use the right directory structure bellow !
sudo systemctl restart nginx
Or you can restart nginx with bash ~/restart_nginx.sh
In order to use versioning we use this directory structure :
/MyAppName
|--/releases
|----/v1.0.0
|----/v1.1.0
|----/v1.2.0
|----/...
|
|--/current -> /releases/v1.2.0 (symlink)
|
|--/logs
|----/access.log
|----/error.log
Create symlink with :
ln -s /home/eljovial/nuxt/my_project/releases/v1.2.0 /home/eljovial/nuxt/my_project/current
Git clone inside version directory instead of pull/merge newest version :
git clone https://$PAT@github.com/GIT_USERNAME/REPOSITORY_NAME.git
To update app just git clone to latest version directory you created, update the symlink, delete older symlink and delete older app.
Make suree to add a .env file inside project directory and add your env variables
touch .env
First of all :
# install dependencies
npm install
# build for production
npm run build
# if static site build with
npm run generate
To run the app in background, inside project directory next to our package.json file, run :
pm2 start npm --name MyAppName -- start
Then, inside project directory, to configure our pm2 config file run :
pm2 init
This will create ecosystem.config.js file, replace its content with :
module.exports = {
apps: [
{
name: 'app_name', // App name that shows in `pm2 ls`
exec_mode: 'cluster', // enables clustering
instances: 'max', // or an integer
cwd: './current', // only if using a subdirectory
script: './node_modules/nuxt/bin/nuxt.js',
args: 'start'
}
]
}
pm2 reload MyAppName
pm2 list
pm2 delete ID_APP
sudo certbot --nginx -d example.com