loading different css base on .env file on nuxt.config.js

239 Views Asked by At

I am trying to load a different css base on my .env file because I have two - three types of application that has different designs.

my nuxt.config.js looks something like this

export default {
  mode: "spa",
  css: process.env.APP_TYPE == 1 ? ["~/assets/scss/app1.scss"] : ["~/assets/scss/app2.scss"]
}

I would like to load 2-3 different scss base on my .env file

1

There are 1 best solutions below

0
On

Create a function before export statement in config that would return css-array. For example:

const getCss = () => {
  return process.env.APP_TYPE == 1 
   ? ["~/assets/scss/app1.scss"] 
   : ["~/assets/scss/app2.scss"]
}
export default {
  mode: "spa",
  css: getCss()
}