Nginx vs. Vite: The Smart Way to Handle Asset Path Prefixes in SPAs
When deploying a Single Page Application (SPA) built with Vite, URL prefixes like /zh/ for internationalization often cause 404 errors for static assets (JS/CSS). This article explores two powerful solutions: first, a quick fix using an Nginx rewrite rule to correct the paths, and second, an advanced approach of setting up a dedicated static domain for content separation and performance optimization. Whether you need a quick fix or a professional deployment architecture, this guide provides clear instructions and code examples.
Vite's `?url` Import Explained: Bundled Code or a Standalone File?
In a Vite project, when you use `import myFile from './path/to/file.js?url'`, is the JS file compiled and bundled? The answer is no. This article provides a deep dive into the powerful `?url` suffix in Vite, explaining how it treats the file as a separate static asset rather than merging its code into your main bundle. Understanding its mechanics and use cases, such as dynamically loading scripts or initializing Web Workers, will help you manage project assets more efficiently. A professional guide from wiki.lib00.com.