简体   繁体   中英

How to include appropriate SCSS file?

I'm using Vue and I have multiple stylesheets for different configuration. And I need to use only one of them (depending on the configuration).

I have config file with value type: "a" , so that I need to include and use "a-setup.scss" . I tried to include file in vue.config.js , but it doesn't support imports.

So the question is: what should I do to use certain scss file?

So, the solution I found is to use css additionalData prop inside the vue.config.js . Code:

 const filename = process.env.VUE_APP_TEMPLATE; const additionalData =... + `@import "src/assets/styles/setup/${ filename }.scss";`; module.exports = { css: { loaderOptions: { sass: { additionalData } } }, ... }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM