Description
Bug description
When deploying a Statamic site with Vite and SSG on Netlify, Vite assets (CSS/JS) are not properly handled in the final static output. Locally, the build process works perfectly with php please ssg:generate, but on Netlify:
The generated static files either miss Vite assets or fail to link them properly.
The build process does not integrate Vite and SSG effectively during deployment.
Expected behavior:
Vite-processed assets (CSS/JS) should be correctly linked in the final static files generated by Statamic's SSG.
How to reproduce
How to Reproduce
Set up a fresh Statamic site with Vite for asset management.
Add the following build command in netlify.toml:
[build]
command = "npm run build && php please ssg:generate"
publish = "storage/app/static"
Deploy the site to Netlify.
Observe the deployed site—Vite assets are either missing or improperly linked.
Logs
No specific errors in the build logs, but the generated CSS and JS files are missing or not linked in the output files in storage/app/static.
Environment
Environment
Here is the output of php please support:details:
Statamic Version: 5.0
Laravel Version: 11.31
Statamic SSG Version: 3.1
PHP Version: 8.2
Node.js Version: 16
Netlify Build Environment: Default
Installation
Fresh statamic/statamic site via CLI
Additional details
Vite Configuration (vite.config.js):
import { defineConfig } from 'vite';
import laravel from 'laravel-vite-plugin';
export default defineConfig({
plugins: [
laravel({
input: [
'resources/css/site.css',
'resources/js/site.js',
],
refresh: true,
}),
],
build: {
outDir: 'public/build',
assetsDir: '',
},
});
Netlify netlify.toml:
[build]
command = "npm run build && php please ssg:generate"
publish = "storage/app/static"
[build.environment]
NODE_VERSION = "16"
PHP_VERSION = "8.2"
See related post on Netlify community page:
https://answers.netlify.com/t/statamic-ssg-at-netlify-failed-to-load-a-stylesheet-from-a-url/111185