4
Help us understand the problem. What are the problem?

More than 1 year has passed since last update.

posted at

updated at

Nuxt.js + Vuetify.js + PurgeCSS

はじまり

Nuxt.js + Vuetify でいい感じのページできた!
SSGでホスティングサイトへシュゥゥゥーッ!!
超!でかいCSS!!(絶望)

PurgeCSS

これがヒントになった。なにが幸いするかわからん。

設定

下記のページを参考にして設定書いたら(というかとりあえずコピペ)Vuetify絡みのCSSのサイズ1/3くらいになりました。
最適化の余地は全然あるけどとりあえずいいか…

nuxt.config.js
  purgeCSS: {
    enabled: ({ isDev }) => !isDev,
    paths: [
      'components/**/*.vue',
      'layouts/**/*.vue',
      'pages/**/*.vue',
      'plugins/**/*.js',
      './node_modules/vuetify/dist/vuetify.js'
    ],
    styleExtensions: ['.css'],
    // whitelist: ['body', 'html', 'nuxt-progress', ''],

    whitelist: ['v-application', 'v-application--wrap','layout','row','col'],
    whitelistPatterns: [
      /^v-((?!application).)*$/,
      /^theme--*/,
      /.*-transition/,
      /^justify-*/,
      /^p*-[0-9]/,
      /^m*-[0-9]/,
      /^text--*/,
      /--text$/,
      /^row-*/,
      /^col-*/,   
    ],
    whitelistPatternsChildren: [/^v-((?!application).)*$/, /^theme--*/],

    extractors: [
      {
        extractor: content => content.match(/[A-z0-9-:\\/]+/g) || [],
        extensions: ['html', 'vue', 'js']
      }
    ]
  },
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Sign upLogin
4
Help us understand the problem. What are the problem?