<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Martin Czerwinski</title>
    <description>The latest articles on DEV Community by Martin Czerwinski (@czerma).</description>
    <link>https://dev.to/czerma</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F966957%2F46958fe9-98a9-4f48-932a-9183311405a9.jpg</url>
      <title>DEV Community: Martin Czerwinski</title>
      <link>https://dev.to/czerma</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/czerma"/>
    <language>en</language>
    <item>
      <title>How to create and minify Vuetify 3 Nuxt 3 project bundle</title>
      <dc:creator>Martin Czerwinski</dc:creator>
      <pubDate>Fri, 30 Dec 2022 02:04:11 +0000</pubDate>
      <link>https://dev.to/czerma/how-to-build-optimized-vuetify-3-nuxt-3-project-4l5k</link>
      <guid>https://dev.to/czerma/how-to-build-optimized-vuetify-3-nuxt-3-project-4l5k</guid>
      <description>&lt;p&gt;Sektions: intro | what is vuetify | get started | about optimization | minimize bundle | conclusion&lt;/p&gt;

&lt;p&gt;&lt;em&gt;&lt;a href="https://github.com/CMQNordic/vuetify-3-nuxt-3-minimal-optimized-starter"&gt;@repo&lt;/a&gt; | &lt;a href="https://magical-peony-07c1dc.netlify.app/"&gt;Netlify live demo)&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Intro&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;In this article I share my knowledge and thoughts about minifing production bundle in a &lt;strong&gt;Nuxt 3 Vuetify 3&lt;/strong&gt; projects by purging unused code.  First part is about what Vuetify 3 is and how to add Vuetify to an existing Nuxt 3 project. Then I'll go into some optimization and minification of js, css and html with practical examples. &lt;/p&gt;

&lt;p&gt;&lt;em&gt;Feel free to check out the final conslusion.&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;What is Vuetify&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Vuetify is Vue component library providing pre-made components and &lt;strong&gt;directives&lt;/strong&gt; to use in front-end projects. A directive is a reusable chunk of code that can be used within a html element. An example is &lt;code&gt;v-ripple&lt;/code&gt; directive that animates background. For example &lt;code&gt;&amp;lt;button v-ripple&amp;gt;click me&amp;lt;/button&amp;gt;&lt;/code&gt; adds a background animation when it's pressed. Vuetify comes with many smaller &lt;strong&gt;components&lt;/strong&gt; to be used as building blocks of layouts. I.e &lt;code&gt;&amp;lt;v-app&amp;gt;&lt;/code&gt; (wrapping whole application and applying themes), or &lt;code&gt;&amp;lt;v-navigation-drawer&amp;gt;&lt;/code&gt; that is a frame sliding in from the side often used as navigation menu on small devices. Some components i.e.&lt;code&gt;v-date-picker&lt;/code&gt; or &lt;code&gt;v-data-table&lt;/code&gt; are more complicated.  Designing and coding those components by ourselfs in Vue (or even worse vanilla javascript) would be a difficult and a time consuming task. Additionally Vutify 3 delivers css features similar to Tailwind. You can use utility classes to control the padding (&lt;em&gt;pa-5&lt;/em&gt;), margin (&lt;em&gt;mb-10&lt;/em&gt;), text color (&lt;em&gt;text-red-lighten-2&lt;/em&gt;), background (&lt;em&gt;bg-orange&lt;/em&gt;), font (&lt;em&gt;text-body-1&lt;/em&gt;), elevation (&lt;em&gt;elevation-3&lt;/em&gt;) and more. Many of them with mobile first variations for displays: &lt;code&gt;xs&lt;/code&gt; (&lt;em&gt;&amp;lt; 600px&lt;/em&gt;), &lt;code&gt;sm&lt;/code&gt; (&lt;em&gt;600px &amp;gt; &amp;lt; 960px&lt;/em&gt;), &lt;code&gt;md&lt;/code&gt; (&lt;em&gt;960px &amp;gt; &amp;lt; 1264px&lt;/em&gt;) and &lt;code&gt;lg&lt;/code&gt; (&lt;em&gt;1264px &amp;gt; &amp;lt; 1904px&lt;/em&gt;). For example class &lt;code&gt;text-md-body-1&lt;/code&gt; applies &lt;code&gt;body-1&lt;/code&gt; font for medium size displays and up.&lt;/p&gt;

&lt;p&gt;Vuetify tegether with Nuxt gained a lot of popularity as they significantly speed up building Vue based applications and prototyping. You can build your whole UI with those predefined components and directives, or just add cherry-picked ones to your project as widgets.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The main concerns&lt;/strong&gt; when adding a library like Vuetify to your project is how it affects the size of code delivered from server to then client (a.k.a the &lt;strong&gt;final bundle&lt;/strong&gt;).&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Get started&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;em&gt;&lt;a href="https://github.com/CMQNordic/vuetify-3-nuxt-3-minimal-optimized-starter"&gt;@repo&lt;/a&gt; | &lt;a href="https://magical-peony-07c1dc.netlify.app/"&gt;Netlify live demo (generate)&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;► Use following simple step to create &lt;strong&gt;new Vuetify 3&lt;/strong&gt; project on top of &lt;strong&gt;Vue 3&lt;/strong&gt;. &lt;br&gt;
&lt;em&gt;Official instructions &lt;a href="https://next.vuetifyjs.com/en/getting-started/installation/#installation"&gt;here&lt;/a&gt;.&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm create vuetify 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;► Use following 4 steps to &lt;strong&gt;add Vuetify 3&lt;/strong&gt; to an &lt;strong&gt;existing Nuxt 3&lt;/strong&gt; project: &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1.&lt;/strong&gt; First (if needed) create a new Nuxt 3 project. &lt;em&gt;Official instructions &lt;a href="https://nuxt.com/docs/getting-started/installation#new-project"&gt;here&lt;/a&gt;.&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx nuxi init  nuxt-3-vuetify-3-minimal-project-starter
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;2.&lt;/strong&gt; Add Vuetify 3 to existing project. &lt;em&gt;Official instructions &lt;a href="https://next.vuetifyjs.com/en/getting-started/installation/#manual-steps"&gt;here&lt;/a&gt;.&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;npm&lt;/span&gt; &lt;span class="nx"&gt;add&lt;/span&gt; &lt;span class="nx"&gt;vuetify&lt;/span&gt;&lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nd"&gt;next&lt;/span&gt;

&lt;span class="c1"&gt;// additionally scraffold new /plugins/vuetify.ts file &lt;/span&gt;
&lt;span class="nx"&gt;npx&lt;/span&gt; &lt;span class="nx"&gt;nuxi&lt;/span&gt; &lt;span class="nx"&gt;add&lt;/span&gt; &lt;span class="nx"&gt;plugin&lt;/span&gt; &lt;span class="nx"&gt;vuetify&lt;/span&gt; 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;3&lt;/strong&gt; Utilize Vuetify by adding following to &lt;code&gt;plugins/vuetify.ts&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;createVuetify&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;vuetify&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;vuetify/styles&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// pre-build css styles&lt;/span&gt;

&lt;span class="cm"&gt;/* Add all components and directives, for dev &amp;amp; prototyping only. */&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="nx"&gt;components&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;vuetify/components&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="nx"&gt;directives&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;vuetify/directives&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="cm"&gt;/* Add build-in icon used internally in various components */&lt;/span&gt;
&lt;span class="cm"&gt;/* Described in https://next.vuetifyjs.com/en/features/icon-fonts/ */&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;mdi&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;aliases&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="nx"&gt;allAliases&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;vuetify/iconsets/mdi-svg&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;aliases&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;allAliases&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nx"&gt;defineNuxtPlugin&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;nuxtApp&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;vuetify&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;createVuetify&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
    &lt;span class="nx"&gt;components&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nx"&gt;directives&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;icons&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="na"&gt;defaultSet&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;mdi&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="nx"&gt;aliases&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;sets&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;mdi&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;});&lt;/span&gt;

  &lt;span class="nx"&gt;nuxtApp&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;vueApp&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;use&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;vuetify&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;server&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;❤️ Initialized Vuetify 3&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;vuetify&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;4&lt;/strong&gt; Instruct Nuxt 3 to transpile Vuetify when building by modifying file &lt;code&gt;nuxt.config.ts&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nx"&gt;defineNuxtConfig&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;  
    &lt;span class="na"&gt;build&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;transpile&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;vuetify&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Finally&lt;/strong&gt; as an additional step in order to have something visual to test with please add following code (basic vuetify components and styling) to &lt;code&gt;app.vue&lt;/code&gt; file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;template&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;div&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;v-app&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;v-navigation-drawer&lt;/span&gt; &lt;span class="na"&gt;temporary&lt;/span&gt; &lt;span class="na"&gt;v-model=&lt;/span&gt;&lt;span class="s"&gt;"showDrawer"&lt;/span&gt; &lt;span class="na"&gt;location=&lt;/span&gt;&lt;span class="s"&gt;"right"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"w-100 text-right"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;v-btn&lt;/span&gt; &lt;span class="na"&gt;flat&lt;/span&gt; &lt;span class="na"&gt;icon=&lt;/span&gt;&lt;span class="s"&gt;"$close"&lt;/span&gt; &lt;span class="na"&gt;size=&lt;/span&gt;&lt;span class="s"&gt;"x-large"&lt;/span&gt; &lt;span class="err"&gt;@&lt;/span&gt;&lt;span class="na"&gt;click=&lt;/span&gt;&lt;span class="s"&gt;"toggle"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;p&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"text-center"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;b&amp;gt;&lt;/span&gt;I'm the drawer&lt;span class="nt"&gt;&amp;lt;/b&amp;gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;/v-navigation-drawer&amp;gt;&lt;/span&gt;

    &lt;span class="nt"&gt;&amp;lt;v-app-bar&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;v-app-bar-nav-icon&lt;/span&gt; &lt;span class="err"&gt;@&lt;/span&gt;&lt;span class="na"&gt;click=&lt;/span&gt;&lt;span class="s"&gt;"toggle"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;v-toolbar-title&amp;gt;&lt;/span&gt;I'm the header&lt;span class="nt"&gt;&amp;lt;/v-toolbar-title&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;/v-app-bar&amp;gt;&lt;/span&gt;

    &lt;span class="nt"&gt;&amp;lt;v-main&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"d-flex align-center"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;v-container&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;v-sheet&lt;/span&gt; &lt;span class="na"&gt;elevation=&lt;/span&gt;&lt;span class="s"&gt;"5"&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"py-4 text-center"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
          &lt;span class="nt"&gt;&amp;lt;h1&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"text-h5"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Built and styled with Vuetify 3&lt;span class="nt"&gt;&amp;lt;/h1&amp;gt;&lt;/span&gt;
          &lt;span class="nt"&gt;&amp;lt;p&amp;gt;&lt;/span&gt;Minimized production bundle (70kB in tot)&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
          &lt;span class="nt"&gt;&amp;lt;v-btn&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"mt-4"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;press me to ripple&lt;span class="nt"&gt;&amp;lt;/v-btn&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;/v-sheet&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;/v-container&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;/v-main&amp;gt;&lt;/span&gt;

    &lt;span class="nt"&gt;&amp;lt;v-footer&lt;/span&gt; &lt;span class="na"&gt;app&lt;/span&gt; &lt;span class="na"&gt;elevation=&lt;/span&gt;&lt;span class="s"&gt;"5"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;v-row&lt;/span&gt; &lt;span class="na"&gt;no-gutters&lt;/span&gt; &lt;span class="na"&gt;justify=&lt;/span&gt;&lt;span class="s"&gt;"center"&lt;/span&gt; 
             &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"text-overline font-weight-black"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;p&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"my-auto"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;I'm the footer&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;v-spacer&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;p&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"my-auto"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;See how I was built&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;v-btn&lt;/span&gt; &lt;span class="na"&gt;icon&lt;/span&gt; &lt;span class="na"&gt;variant=&lt;/span&gt;&lt;span class="s"&gt;"plain"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
          &lt;span class="nt"&gt;&amp;lt;v-icon&lt;/span&gt; &lt;span class="na"&gt;icon=&lt;/span&gt;&lt;span class="s"&gt;"$info"&lt;/span&gt; &lt;span class="na"&gt;color=&lt;/span&gt;&lt;span class="s"&gt;"green-accent-4"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;/v-btn&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;/v-row&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;/v-footer&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/v-app&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/template&amp;gt;&lt;/span&gt;

&lt;span class="nt"&gt;&amp;lt;script &lt;/span&gt;&lt;span class="na"&gt;setup&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;showDrawer&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;ref&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;toggle&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;usedToggle()&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="nx"&gt;showDrawer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;showDrawer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;};&lt;/span&gt;

  &lt;span class="cm"&gt;/* Redundant unused code to test treeshaking */&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;unusedFunction&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;unusedFunction&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;

&lt;span class="nt"&gt;&amp;lt;style&amp;gt;&lt;/span&gt;
  &lt;span class="c"&gt;/* Redundant unused code to test treeshaking */&lt;/span&gt;
  &lt;span class="nc"&gt;.unused-selector-app&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;orange&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/style&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now run &lt;code&gt;npm run dev&lt;/code&gt; and verify the page looks like in the live demo &lt;a href="https://magical-peony-07c1dc.netlify.app/"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Now run &lt;code&gt;npm run generate&lt;/code&gt; followed by &lt;code&gt;npm run preview&lt;/code&gt;. &lt;em&gt;Because we have SSR set to true by default, Nuxt 3 will generate a static project in &lt;code&gt;.output/public/&lt;/code&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;🩻&lt;strong&gt;Analazing generated bundle:&lt;/strong&gt;&lt;br&gt;
&lt;code&gt;.output/public/index.html&lt;/code&gt;  14kB (3kB gzipped)&lt;br&gt;
&lt;code&gt;.output/public/_nuxt/enter.xxx.js&lt;/code&gt;  408kB  (125kB gzipped)&lt;br&gt;
&lt;code&gt;.output/public/_nuxt/enter.xxx.css&lt;/code&gt; 371kB (51kB gzipped)&lt;/p&gt;

&lt;p&gt;The production bundle is &lt;strong&gt;"huge"&lt;/strong&gt; for the simplicity of this project 👎&lt;/p&gt;

&lt;p&gt;Read further why and what we can do about it.&lt;/p&gt;
&lt;h3&gt;
  
  
  &lt;strong&gt;About optimization and customization of Vuetify 3&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;In initial setup, in file &lt;code&gt;vuetify.ts&lt;/code&gt;, we add ALL components and directives, import ALL pre-build css style selectors and ALL default icon aliases. It is ok for prototyping but it's not very optimal for production as generated bundle contains too much unused code.&lt;/p&gt;

&lt;p&gt;Becouse we here for test purposes impoement whole site in one single file &lt;code&gt;app.vue&lt;/code&gt; (without any routes) then our statically generated bundle consists of 3 main, easy to analyze parts:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;.output/public/index.html&lt;/code&gt; (refered to as &lt;strong&gt;html bundle&lt;/strong&gt;)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;.output/public/_nuxt/enter.xxx.js&lt;/code&gt; (refered to as &lt;strong&gt;js bundle&lt;/strong&gt;)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;.output/public/_nuxt/enter.xxx.css&lt;/code&gt; (refered to as &lt;strong&gt;css bundle&lt;/strong&gt;)&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;What happens to unused js code?&lt;/strong&gt;&lt;br&gt;
Search js bundle for phrase: &lt;em&gt;'unusedFunction'&lt;/em&gt;  -&amp;gt; not found 👍&lt;br&gt;
Search js bundle for phrase: &lt;em&gt;'toggle'&lt;/em&gt; -&amp;gt; found 👍&lt;br&gt;
Both of those are defined in the bottom of &lt;code&gt;app.vue&lt;/code&gt;, one is used the other not. We verify here that Vite by default removes all unused imported or defined javascript when bundling. That's good. 👍  &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What happens to unused icons aliases?&lt;/strong&gt;&lt;br&gt;
Search js bundle for phrase: &lt;em&gt;'mdi-info'&lt;/em&gt;  -&amp;gt; found 👍&lt;br&gt;
Search js bundle for phrase: &lt;em&gt;'mdi-minus'&lt;/em&gt; -&amp;gt; found 👎&lt;br&gt;
We find out that all icons are found despite the fact we use only icon aliases: menu ("hamburger" used internally by &lt;code&gt;&amp;lt;v-app-bar-nav-icon /&amp;gt;&lt;/code&gt;), close_ and info icons. That's less good. 👎&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What happens to unused css selectors?&lt;/strong&gt;&lt;br&gt;
Search css bundle for phrase: &lt;em&gt;'unused-selector-app'&lt;/em&gt;  -&amp;gt; found 👎&lt;br&gt;
Search css bundle for phrase: &lt;em&gt;'bg-red-lighten-4'&lt;/em&gt;  -&amp;gt; found 👎&lt;br&gt;
Search css bundle for phrase: &lt;em&gt;'my-sm-9'&lt;/em&gt; -&amp;gt; found 👎&lt;br&gt;
None of the selecors above (first one defined by us in &lt;code&gt;app.vue&lt;/code&gt; and two other ones added by vuetify) is used nowhere but in the bundle we find ALL selectors from imported &lt;code&gt;vuetify/styles&lt;/code&gt; and everything from &lt;code&gt;&amp;lt;styles&amp;gt;&lt;/code&gt; part of &lt;code&gt;app.vue&lt;/code&gt; file. This despite the fact that our simple project only use some few of those. 👎&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;As on dec 2022 Nuxt staticaly generates bundle (npm run generate) and injects &lt;code&gt;&amp;lt;styles&amp;gt;&lt;/code&gt; part from &lt;code&gt;app.vue&lt;/code&gt; (scoped or not) into &lt;strong&gt;html head&lt;/strong&gt; for &lt;strong&gt;each&lt;/strong&gt; generated page. Keep this in mind when you introduce lots of global styles in &lt;code&gt;app.vue&lt;/code&gt; file, as all those styles will be part of html code for each requested page.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;It must be mentioned that removal of unused css is a major issue in many projects and a topic of many discussions. There does not exist any perfect tool for it at the writing moment. In order not to remove too much we must have knowledge of how removal works and we must have good knowledge about the code whe want to purge. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Most important to remember&lt;/strong&gt; here is that there  might me a lot of unused css code both in html head and subsequently loaded css files. &lt;/p&gt;

&lt;p&gt;So.. how do we securly remove all this unused code? Keep on reading.&lt;/p&gt;

&lt;p&gt;Vuetify 3 provides functionality called &lt;strong&gt;treeshaking&lt;/strong&gt; that removes unused components from final bundle, or more correctly adds only used ones. You can read official documentation &lt;a href="https://next.vuetifyjs.com/en/features/treeshaking/#treeshaking"&gt;here&lt;/a&gt;. Unfortunately this treeshaking  optimization aim for javascript bundle. It &lt;strong&gt;does not remove&lt;/strong&gt; all unused &lt;strong&gt;css selectors&lt;/strong&gt;!&lt;/p&gt;

&lt;p&gt;At writing moment I found a plugin named &lt;strong&gt;nuxt-purgecss&lt;/strong&gt; to be the best option (still not optimal) to remove unused CSS code from final build bundle.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;I recommend to read this good article on the topic - &lt;a href="https://css-tricks.com/how-do-you-remove-unused-css-from-a-site/"&gt;How Do You Remove Unused CSS From a Site?&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Finally shortly about customization of Vuetify 3 project&lt;/strong&gt;&lt;br&gt;
Vuetify 3 uses SASS to craft all styles for the framework. By default it delivers pre-compiled CSS for all styles, including themes &lt;code&gt;light&lt;/code&gt; and &lt;code&gt;dark&lt;/code&gt;. Sometimes it's desired to re-build to manipulate the sass variables to get a feel-and-look for our needs. Some variables in vuetify are used for general styles and themes but unfortunately others are nested and used inside the components (aka. component specific variables).&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;We can customize many SASS variables in Vuetify 3 and rebuild framework styles at build time. Read more about how to do it &lt;a href="https://next.vuetifyjs.com/en/features/sass-variables/"&gt;here&lt;/a&gt;. By my opinion if possible this &lt;strong&gt;deep variable customisation&lt;/strong&gt; should be &lt;strong&gt;avoided&lt;/strong&gt;. I do not recommend it as it works right now. There are other more simple and faster ways to overwrite themes, colors, backgrounds, font styles for body and heading etc.&lt;/p&gt;

&lt;p&gt;Note! Enabling &lt;strong&gt;deep variable customisation&lt;/strong&gt; will have major impact on dev and build strt-up duratin and might slow down the development significantly if your project uses more than some few components.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;em&gt;Customization of icons, fonts, styles and themes is a big topic on its own. You can give it a read in my other article just about this topic - &lt;a href="https://github.com/CMQNordic/vuetify-3-nuxt-3-minimal-optimized-starter"&gt;How to customize icons, fonts, styles and themes in Vuetify 3 project&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  &lt;strong&gt;Minimize Vuetify 3 bundle&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Let's get our hands dirty.&lt;/p&gt;
&lt;h4&gt;
  
  
  1. Vuetify treeshaking
&lt;/h4&gt;

&lt;p&gt;To auto inculde only used vuetify components and directives (a.k.a &lt;a href="https://next.vuetifyjs.com/en/features/treeshaking/#treeshaking"&gt;automatic treeshaking&lt;/a&gt;) we must install required dependency.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm i -D vite-plugin-vuetify
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then we need to modify following in our project:&lt;/p&gt;

&lt;p&gt;Remove imports of ALL components and directives from &lt;code&gt;plugins/vuetify.ts&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt; &lt;span class="p"&gt;...&lt;/span&gt;

&lt;span class="cm"&gt;/* Add all components and directives, test &amp;amp; prototyping only. */&lt;/span&gt;
&lt;span class="c1"&gt;// REMOVE! import * as components from 'vuetify/components';&lt;/span&gt;
&lt;span class="c1"&gt;// REMOVE! import * as directives from 'vuetify/directives';&lt;/span&gt;

&lt;span class="p"&gt;...&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nx"&gt;defineNuxtPlugin&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;nuxtApp&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;vuetify&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;createVuetify&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
      &lt;span class="c1"&gt;// REMOVE! components,  &lt;/span&gt;
      &lt;span class="c1"&gt;// REMOVE! directives,   &lt;/span&gt;
      &lt;span class="na"&gt;icons&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
          &lt;span class="na"&gt;defaultSet&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;mdi&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
          &lt;span class="nx"&gt;aliases&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
          &lt;span class="na"&gt;sets&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;mdi&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;});&lt;/span&gt;

  &lt;span class="p"&gt;...&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Add treeshaking istructions for Vite in &lt;code&gt;nuxt.config.ts&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;
&lt;span class="cm"&gt;/* ADD! */&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;vuetify&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;vite-plugin-vuetify&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nx"&gt;defineNuxtConfig&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="p"&gt;...&lt;/span&gt;

  &lt;span class="cm"&gt;/* ADD! */&lt;/span&gt;
  &lt;span class="na"&gt;modules&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="cm"&gt;/* Treeshaking: https://next.vuetifyjs.com/en/features/treeshaking/ */&lt;/span&gt;
    &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;options&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;nuxt&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nx"&gt;nuxt&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;hooks&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;hook&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;vite:extendConfig&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;config&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
          &lt;span class="nx"&gt;config&lt;/span&gt;&lt;span class="p"&gt;?.&lt;/span&gt;&lt;span class="nx"&gt;plugins&lt;/span&gt;&lt;span class="p"&gt;?.&lt;/span&gt;&lt;span class="nx"&gt;push&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;vuetify&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt;
       &lt;span class="p"&gt;});&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;],&lt;/span&gt;

  &lt;span class="p"&gt;...&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Thats all. When running the project with &lt;code&gt;npm run generate&lt;/code&gt; followed by &lt;code&gt;npm run preview&lt;/code&gt; you will generate static files in &lt;code&gt;.output/public/&lt;/code&gt; folder. &lt;/p&gt;

&lt;p&gt;🩻&lt;strong&gt;Analazing generated bundle after treeshaking:&lt;/strong&gt;&lt;br&gt;
&lt;code&gt;.output/public/index.html&lt;/code&gt;  14kB (3kB gzipped)&lt;br&gt;
&lt;code&gt;.output/public/_nuxt/enter.xxx.js&lt;/code&gt; 184kB (67kB gzipped) &lt;br&gt;
&lt;code&gt;.output/public/_nuxt/enter.xxx.css&lt;/code&gt; 277kB  (34kB gzipped)&lt;/p&gt;

&lt;p&gt;Our bundle is now &lt;strong&gt;smaller&lt;/strong&gt; as js bundle was before 408kB (125kB gzipped). Treeshaking did a good job. 👍&lt;/p&gt;
&lt;h4&gt;
  
  
  2. Theme and icons Optimization
&lt;/h4&gt;

&lt;p&gt;Ee only use 3 icons aliases: &lt;em&gt;menu&lt;/em&gt;, &lt;em&gt;close&lt;/em&gt; and &lt;em&gt;info&lt;/em&gt;. Loading only the used ones will minimize internal vuetify object in browser (on heap). Have this in mind when you later add more external icons to your project.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Add only used icons&lt;/strong&gt; by changing in &lt;code&gt;plugins/vuetify.ts&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="p"&gt;...&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;mdi&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;aliases&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="nx"&gt;allAliases&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;vuetify/iconsets/mdi-svg&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="cm"&gt;/* REMOVE */&lt;/span&gt; &lt;span class="c1"&gt;// const aliases = allAliases; &lt;/span&gt;

&lt;span class="cm"&gt;/* ADD */&lt;/span&gt; 
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;aliases&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="cm"&gt;/* Only used icon aliases here */&lt;/span&gt;
    &lt;span class="na"&gt;menu&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;allAliases&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;menu&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;close&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;allAliases&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;close&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;info&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;allAliases&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;info&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="p"&gt;...&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;vuetify&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;createVuetify&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;icons&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="na"&gt;defaultSet&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;mdi&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="nx"&gt;aliases&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;sets&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;mdi&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="p"&gt;});&lt;/span&gt; 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Generally we shall always add only used icons to the project and now whole libraries..&lt;/p&gt;

&lt;p&gt;What about themes? &lt;br&gt;
When we analyze the created html bundle notice a large section &lt;code&gt;&amp;lt;style id="vuetify-theme-stylesheet"&amp;gt;&lt;/code&gt;  in the html head. Read more about it in official documentation &lt;a href="https://next.vuetifyjs.com/en/features/theme/#implementation"&gt;here&lt;/a&gt;. It contains whole configuration for &lt;em&gt;v-theme--light&lt;/em&gt;, &lt;em&gt;v-theme--dark&lt;/em&gt; and lots of generated selectors for each color configuration.&lt;/p&gt;

&lt;p&gt;We did not specify any theme to use but by default theme &lt;em&gt;light&lt;/em&gt; was applied to everything within the &lt;code&gt;v-app&lt;/code&gt; block. Therfore in generated &lt;code&gt;index.html&lt;/code&gt; we can see that many elements use selectors &lt;code&gt;v-theme--light&lt;/code&gt;. But what if we disable themes in Vuetify totally? Will this section with unnecessary unused theme selectors and variables disapear? Lets try..&lt;/p&gt;

&lt;p&gt;We can try to &lt;strong&gt;disable themes&lt;/strong&gt; as described &lt;a href="https://next.vuetifyjs.com/en/features/theme/#disable-theme"&gt;here&lt;/a&gt; in &lt;code&gt;plugins/vuetify.ts&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nx"&gt;createVuetify&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="cm"&gt;/* ADD */&lt;/span&gt; &lt;span class="na"&gt;theme&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; 
  &lt;span class="p"&gt;...&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After re-generating no theme selectors are applied anymore on any html elements, good, disabling of themes worked as expected. But... the &lt;code&gt;&amp;lt;style id="vuetify-theme-stylesheet"&amp;gt;&lt;/code&gt; section with unused selectors still remains as before in the head of generated index.html file. 👎&lt;/p&gt;

&lt;p&gt;Consider this a bug? Why does Vuetify add thise "disabled" code? Is there any way to remove all this redundand code, or only enable &lt;code&gt;light&lt;/code&gt; theme and not &lt;code&gt;dark&lt;/code&gt; to reduce amout of added code in html head? &lt;em&gt;To be updated when I know, but feel free to comment this in comments!&lt;/em&gt;&lt;/p&gt;

&lt;h5&gt;
  
  
  3. Clean out unused CSS
&lt;/h5&gt;

&lt;p&gt;Purge-css is a "dummy" tool. It scans files (html, vue, js ) on locations that we provide to it, and creates a list with selectors it marks as used. Then it analyzes the final generated css code created by our bundler and removes all selectors from it that are not part of its "found-used-selectors" list. For example: In file x.html with &lt;code&gt;&amp;lt;p class="bg-red"&amp;gt;&lt;/code&gt; it will find &lt;code&gt;bg-red&lt;/code&gt;. In file y.vue with &lt;code&gt;&amp;lt;v-btn class="elevation-6" elevation='1'&amp;gt;&lt;/code&gt; it find &lt;code&gt;elevation-6&lt;/code&gt; but NOT &lt;code&gt;elevation-1&lt;/code&gt; becouse the latter is created with help of a prop. Subsequently &lt;code&gt;bg-red&lt;/code&gt; and &lt;code&gt;elevation-6&lt;/code&gt; will not be removed, while &lt;code&gt;elevation-1&lt;/code&gt; will not exist in the final bundle!&lt;/p&gt;

&lt;p&gt;It is essential to instruct purgecss to look in all locations of project where source code used by bundler is located. For Nuxt framework it is predefined by the nuxt-purgecss plugin (default nuxt-purgecss settings &lt;a href="https://github.com/Developmint/nuxt-purgecss/blob/main/src/config.ts"&gt;here&lt;/a&gt;) but it becomes tricky with third party librarys like Vuetify where the components and selectors are created by render functions defined deep down in &lt;code&gt;node_modules/vuetify&lt;/code&gt; folder and some classes might even sometimes be rendered at run time in client. Additionally Vuetify 3 generates some of its its style selectors based on props whic does not help us here.&lt;/p&gt;

&lt;p&gt;We need to configure &lt;strong&gt;purgecss&lt;/strong&gt; to be sure it &lt;strong&gt;only remove&lt;/strong&gt; unused code. So how can we handle it?&lt;/p&gt;

&lt;p&gt;I like using Vuetify with Nuxt and it is often for the possibilty of &lt;strong&gt;following little trick&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;First &lt;strong&gt;build a static site&lt;/strong&gt; as nuxt provides this in an easy way (css: true + npm run generate). Then ALL html shall be generated with all classes and selectors in &lt;code&gt;dist&lt;/code&gt; folder.&lt;/p&gt;

&lt;p&gt;After first build &lt;strong&gt;provide the content&lt;/strong&gt; of the &lt;code&gt;dist&lt;/code&gt; folder (&lt;strong&gt;copy of it&lt;/strong&gt;) to purgecss as a input option "content: " and do your final production build. Then purge will have all class names and selector it needs to keep.&lt;/p&gt;

&lt;p&gt;First install the nuxt-purgecss plugin&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm i &lt;span class="nt"&gt;-D&lt;/span&gt; nuxt-purgecss 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Add purgecss module and with settings in &lt;code&gt;nuxt.config.ts&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="p"&gt;...&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nx"&gt;defineNuxtConfig&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;modules&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="p"&gt;...&lt;/span&gt;

    &lt;span class="cm"&gt;/* ADD */&lt;/span&gt; 
    &lt;span class="cm"&gt;/* Remove unused CSS */&lt;/span&gt;
    &lt;span class="p"&gt;[&lt;/span&gt;
      &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;nuxt-purgecss&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;content&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
          &lt;span class="cm"&gt;/* Copy of 'dist' from first npm run generate */&lt;/span&gt;
          &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;modules/purgecss/static-generated-html/**/*.html&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="p"&gt;],&lt;/span&gt;
        &lt;span class="na"&gt;greedy&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
          &lt;span class="cm"&gt;/* Generated as runtime, keep all related selectors */&lt;/span&gt;
          &lt;span class="sr"&gt;/v-ripple/&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="p"&gt;],&lt;/span&gt;
      &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="p"&gt;]&lt;/span&gt;
  &lt;span class="p"&gt;]&lt;/span&gt;

  &lt;span class="p"&gt;...&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After all those modifications run now 'npm run generate', copy content of 'dist' to new folder 'modules/purgecss/static-generated-html', run 'npm run generate' again followed by 'npm run preview'. &lt;br&gt;
This generate static files in '.output/public/' folder. &lt;/p&gt;

&lt;p&gt;🩻&lt;strong&gt;Analazing generated file after treeshaking and csspurge:&lt;/strong&gt;&lt;br&gt;
&lt;code&gt;.output/public/index.html&lt;/code&gt;  14kB (3kB gzipped)&lt;br&gt;
&lt;code&gt;.output/public/_nuxt/enter.xxx.js&lt;/code&gt;  184kB  (67kB gzipped)&lt;br&gt;
&lt;code&gt;.output/public/_nuxt/enter.xxx.css&lt;/code&gt; 14kB  (3.4kB gzipped)&lt;/p&gt;

&lt;p&gt;The css is much much smaller than from beggining.👍 &lt;br&gt;
We started with css bundle of &lt;strong&gt;371kB&lt;/strong&gt; and ended up with &lt;strong&gt;14kB&lt;/strong&gt; (unzipped). Thats a pretty awsome reduction. 😀&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;CONCLUSION&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;We created an educational project starter using Vuetify 3 on top of Nuxt 3. We did some optimization to remove unused code from js,css and html in the production bundle. Them we deployed the project.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;&lt;a href="https://github.com/CMQNordic/vuetify-3-nuxt-3-minimal-optimized-starter"&gt;@repo&lt;/a&gt; | &lt;a href="https://magical-peony-07c1dc.netlify.app/"&gt;Netlify live demo (generate)&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;BEFORE OPTIMIZATION&lt;br&gt;
&lt;code&gt;.output/public/index.html&lt;/code&gt;  14kB (3kB gzipped)&lt;br&gt;
&lt;code&gt;.output/public/_nuxt/enter.xxx.js&lt;/code&gt;  408kB  (125kB gzipped)&lt;br&gt;
&lt;code&gt;.output/public/_nuxt/enter.xxx.css&lt;/code&gt; 371kB (51kB gzipped)&lt;/p&gt;

&lt;p&gt;AFTER OPTIMIZATION&lt;br&gt;
&lt;code&gt;.output/public/index.html&lt;/code&gt;  14kB (3kB gzipped)&lt;br&gt;
&lt;code&gt;.output/public/_nuxt/enter.xxx.js&lt;/code&gt;  184kB  (67kB gzipped)&lt;br&gt;
&lt;code&gt;.output/public/_nuxt/enter.xxx.css&lt;/code&gt; 14kB  (3.4kB gzipped)&lt;/p&gt;

&lt;p&gt;IWe reduced the totla bundle size approx &lt;strong&gt;795kB&lt;/strong&gt; to &lt;strong&gt;212kB&lt;/strong&gt; (zipped from &lt;strong&gt;179kB&lt;/strong&gt; to &lt;strong&gt;73kB&lt;/strong&gt;). Around 50kb of the zipped size is pure default and always-included Vue+Nuxt base functionality!&lt;br&gt;
Total reduction of almost 80%.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;I know that index.html contains some more unused theme code. At writing moment I have no solution for that but will update here asap I know.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Additionaly we learned that when building site statically with nuxt and adding styles in &lt;code&gt;app.vue&lt;/code&gt; file, then those styles are always added to head section of all generted html pages. This is something to have in mind when adding styles there and build static site.&lt;/p&gt;

&lt;p&gt;Do you have any comment what more can be done to minimize bundle for this starter even more?&lt;/p&gt;

&lt;p&gt;I really hope you did learn something usefull in this article.&lt;/p&gt;

&lt;p&gt;✌️&lt;/p&gt;

</description>
      <category>nuxt3</category>
      <category>vuetify3</category>
      <category>purgecss</category>
      <category>bundle</category>
    </item>
  </channel>
</rss>
