Skip to content

Instantly share code, notes, and snippets.

@dkesberg
Created February 22, 2023 08:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dkesberg/4e87216a768963f15ed1f6c276a0c2b5 to your computer and use it in GitHub Desktop.
Save dkesberg/4e87216a768963f15ed1f6c276a0c2b5 to your computer and use it in GitHub Desktop.
Vue JS subdirectory setup for /directory
VITE_BASE="/directory/"
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /directory/
RewriteRule ^directory/index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /directory/index.html [L]
</IfModule>
import { fileURLToPath, URL } from "node:url";
import { defineConfig, loadEnv } from "vite";
import vue from "@vitejs/plugin-vue";
// https://vitejs.dev/config/
export default defineConfig(({ command, mode }) => {
const env = loadEnv(mode, process.cwd(), '');
const base = env.VITE_BASE || '/';
return {
plugins: [vue()],
base: base,
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url))
}
}
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment