V
V
vimirtv2019-03-26 15:38:28
JavaScript
vimirtv, 2019-03-26 15:38:28

How to load sass depending on the selected condition?

I'm doing a project on nuxt. Such a task is worth it.
There are three different html templates. Templates will change depending on what came from the server.
Each template has its own SASS file.
Is there a way to load different styles?
For example, the server returned "Template 1" I load main1.sass

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey Okhotnikov, 2019-03-26
@tsepen

const addLink = path => {
  let link = document.createElement("link")
  link.setAttribute("rel", "stylesheet")
  link.setAttribute("href", path)

  document.getElementsByTagName("head")[0].appendChild(link)
}

const templatenumber = 1

addLink('./style' + templatenumber + '.scss')

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question