The Stratox Static Site Generator (SSG) is a lightweight tool that transforms your dynamic Stratox application into static HTML files. This approach enhances site performance, boosts SEO, and makes deployment a breeze.
- Flexible Configuration: Customize the build process with options for port, host, and SSL.
- Dynamic to Static: Generate static HTML files for specific routes.
- SEO-Friendly: Optimized output for better search engine visibility.
- Ensure Node.js is installed on your system.
- Install Stratox SSG via npm:
npm install @stratox/ssg --save-dev
Edit your vite.config.js
file to specify the paths you want to generate as static HTML.
import { defineConfig } from 'vite';
export default defineConfig({
stratoxSSG: {
paths: [
'/',
'/about',
'/contact'
]
}
});
Run the following commands to build your static files:
-
Basic Build:
npx ssg build
This command generates static files and outputs them to the
dist
directory. -
Custom Port: To specify a custom port for the build script to access, use:
npx ssg build --port 5193
-
Custom Host: To specify a custom host for the build script, use:
npx ssg build --host example.test
-
Enable HTTPS: To use HTTPS for the build script, add the
--ssl
option:npx ssg build --ssl true
After building your static files, deploy the contents of the dist
directory to your preferred hosting platform (e.g., Netlify, Vercel, or your own server).
After running the ssg build
command, your project directory might look like this:
project-root/
├── dist/
│ ├── assets/
│ ├── index.html
│ ├── about.html
│ └── contact.html
├── src/
├── vite.config.js
└── package.json
- Automated Builds: Add the build command to your
package.json
scripts for easier execution:Then run:"scripts": { "build:ssg": "ssg build" }
npm run build:ssg