Move your CSS files to the public folder:
public/assets/css/step1.css
public/assets/css/step2.css
Then, use useHead() in each page (or in your layout) to load the corresponding CSS dynamically:
<!-- pages/login/step1.vue -->
<script setup>
useHead({
link: [
{ rel: 'stylesheet', href: '/css/step1.css' }
]
})
</script>
<template>
<div>
Step 1 content
</div>
</template>
<!-- pages/login/step2.vue -->
<script setup>
useHead({
link: [
{ rel: 'stylesheet', href: '/css/step2.css' }
]
})
</script>
<template>
<div>
Step 2 content
</div>
</template>
Files in assets/ are processed by Webpack and are not directly accessible via /assets/... in the browser.
Files in public/ are served as-is and can be accessed directly with /filename.css.
public/css/step1.css
js
Copy code
useHead({
link: [
{ rel: 'stylesheet', href: '/css/step1.css' }
]
});
Wrong:
js
Copy code
href: '/assets/css/step1.css' this will fail in browser
I hope this helps solve your issue.