【问题标题】:How to pass env variable in scss using stencil-sass plugin如何使用 stencil-sass 插件在 scss 中传递 env 变量
【发布时间】:2020-10-16 17:27:26
【问题描述】:

我有一个要求,我必须通过读取环境变量来应用条件样式。 如果(模式=生产) {产品 css 链接} 别的 {开发 CSS 链接}

import { Config } from '@stencil/core'
import { sass } from '@stencil/sass'

export const config: Config = {

plugins: [
 sass('**HERE I NEED TO PASS ENV VARIABLE**')
]
}

【问题讨论】:

    标签: typescript ionic-framework sass stenciljs


    【解决方案1】:

    您可以使用 env 变量来注入不同的全局路径(请参阅https://github.com/ionic-team/stencil-sass#inject-globals-sass-paths):

    export const config: Config = {
      plugins: [
        sass({
          injectGlobalPaths: [
            process.env.MY_VAR === 'foo'
              ? 'src/global/variables-one.scss'
              : 'src/global/variables-two.scss',
          ],
        }),
      ],
    }
    

    【讨论】:

      猜你喜欢
      • 2020-10-29
      • 2021-04-09
      • 2020-01-30
      • 1970-01-01
      • 1970-01-01
      • 2018-09-28
      • 2018-01-07
      • 1970-01-01
      • 2021-12-13
      相关资源
      最近更新 更多