Vue-multiselect: CSS not showing in Nuxt Production

Created on 21 Oct 2019  路  2Comments  路  Source: shentao/vue-multiselect

When deploying the project with Nuxt (npm run build) the styles don't show properly.
I've tried to use the Nuxt module and didn't work at build, but at dev work perfectly.

Most helpful comment

Hey @ardasatata thanks for your comment!
I had tried putting the Global CSS links and didn't work.

I've finally discovered it was because I'm also using TailwindCSS with the nuxt-tailwindcss plugin and the classes were deleted on the PurgueCSS.

What has finally worked has been adding to my nuxt.config.js in the PurgueCSS whitelistPatterns section a multiselect value (and also added the nuxt transitions, because didn't work on production):

export default {
  purgeCSS: {
    whitelistPatterns: [
      /-(leave|enter|appear)(|-(to|from|active))$/,
      /^(?!(|.*?:)cursor-move).+-move$/,
      /^nuxt-link(|-exact)-active$/,
      /multiselect/
    ]
  }
}

All 2 comments

I figured it out after 5 hours trying lol

Just add this to your css on nuxt.config.js

  /*
   ** Global CSS
   */
  css: [
    '~/assets/css/tailwind.css',
    '~/assets/css/main.css',
    '~/node_modules/vue-multiselect/dist/vue-multiselect.min.css'
  ],

hope this helps!

EDIT:

I think it is because of my extractCSS config in nuxt.config I set it to false and all of 3rd party node modules CSS seems loaded normally

build: {
    transpile: ['vuejs-paginate', 'vue-loading-spinner'],
    postcss: {
      // Add plugin names as key and arguments as value
      // Install them before as dependencies with npm or yarn
      plugins: {
        // Disable a plugin by passing false as value
        tailwindcss: path.resolve(__dirname, './tailwind.config.js')
      },
      preset: {
        // Change the postcss-preset-env settings
        autoprefixer: {
          grid: true
        }
      }
    },
    splitChunks: {
      layouts: false
    },
    extractCSS: false
  },

Hey @ardasatata thanks for your comment!
I had tried putting the Global CSS links and didn't work.

I've finally discovered it was because I'm also using TailwindCSS with the nuxt-tailwindcss plugin and the classes were deleted on the PurgueCSS.

What has finally worked has been adding to my nuxt.config.js in the PurgueCSS whitelistPatterns section a multiselect value (and also added the nuxt transitions, because didn't work on production):

export default {
  purgeCSS: {
    whitelistPatterns: [
      /-(leave|enter|appear)(|-(to|from|active))$/,
      /^(?!(|.*?:)cursor-move).+-move$/,
      /^nuxt-link(|-exact)-active$/,
      /multiselect/
    ]
  }
}
Was this page helpful?
0 / 5 - 0 ratings

Related issues

icebob picture icebob  路  4Comments

wujekbogdan picture wujekbogdan  路  4Comments

yaakovp picture yaakovp  路  3Comments

Uninen picture Uninen  路  4Comments

xereda picture xereda  路  4Comments