🪴 Rhitik's Notebook

Search

Search IconIcon to open search

Nuxt - Paying attention to detail

Last updated Dec 11, 2023 Edit Source

In this note, I will just jot down a few points that are easy to overlook while developing a Nuxt application.

My focus is on a server side rendered website, as I am Learning Nuxt 3 for an SSR project. So I might overlook some of the things in the sections around Client Side Rendering.

# Dynamic imports of CSS in JS are not server side compatible

Discouraged ❌

1
2
3
4
5
6
7
<script>
// Use a static import for server-side compatibility
import '~/assets/css/first.css'

// Caution: Dynamic imports are not server-side compatible
import('~/assets/css/first.css')
</script>

Recommended ✅

1
2
3
<style>
@import url("~/assets/css/second.css");
</style>