-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to Set Up Vite with Statamic SSG on Netlify #185
Comments
Additional Details and Debugging Efforts Build Command Variations
and alternative paths like public/storage/app/static or build/storage/app/static. None resolved the issue. Asset Manifest Troubleshooting Testing with base Configuration Comparison with Local Build Questions for Statamic/Vite Developers Future Considerations If no clear resolution is found, I’m considering migrating to Vercel or another platform to see if their build pipeline is more compatible with this setup. Would the Statamic or Vite team have any recommendations on preferred hosting providers for similar setups? |
Follow-Up: Asset Duplication and Incorrect Linking Persists Hi Statamic/Vite Team, I've implemented the following configurations based on earlier suggestions to resolve the asset duplication and linking issues: 1. Vite Configuration (vite.config.js):
import { defineConfig } from 'vite';
import laravel from 'laravel-vite-plugin';
export default defineConfig({
base: './',
plugins: [
laravel({
input: [
'resources/css/site.css',
'resources/js/site.js',
],
refresh: true,
}),
],
build: {
outDir: 'public/build',
rollupOptions: {
output: {
entryFileNames: 'assets/[name]-[hash].js',
chunkFileNames: 'assets/[name]-[hash].js',
assetFileNames: 'assets/[name]-[hash].[ext]',
},
},
chunkSizeWarningLimit: 1000,
},
}); 2. Statamic SSG Configuration (ssg.php):
'copy' => [
public_path('assets') => 'assets', // For static assets like images, fonts
public_path('build/assets') => 'assets/build', // For Vite-built assets
public_path('css') => 'css',
public_path('js') => 'js',
public_path('favicon.ico') => 'favicon.ico',
], 3. Template Adjustment:
{{ vite src="resources/css/site.css|resources/js/site.js" directory="assets/build" }} Netlify Configuration (netlify.toml):
[build]
command = "npm run build && php please ssg:generate"
publish = "storage/app/static"
[build.environment]
NODE_VERSION = "16"
PHP_VERSION = "8.2" Current Outcome:
Questions:
Any insights or recommendations would be greatly appreciated. If this is a bug, could you provide guidance on how to proceed or any workarounds? Thank you for your support! |
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:
Deploy the site to Netlify.
Observe the deployed site—Vite assets are either missing or improperly linked.
Logs
Environment
Installation
Fresh statamic/statamic site via CLI
Additional details
Vite Configuration (vite.config.js):
Netlify netlify.toml:
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
The text was updated successfully, but these errors were encountered: