Make environment variables available as Sass variables in Vue.js.
Forked from steveholgado/- vuejs-sass-environment-variables.md
Created
November 18, 2020 00:46
-
-
Save Yemolai/07aa28498858f6d8e02af23f3e2e8825 to your computer and use it in GitHub Desktop.
Make environment variables available as Sass variables in Vue.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CONDITION="true" | |
COLOR="red" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<div class="example"> | |
Example | |
</div> | |
</template> | |
<script> | |
export default { | |
name: 'Example' | |
} | |
</script> | |
<style lang="scss"> | |
.example { | |
color: black; | |
@if $CONDITION == true { | |
color: $COLOR; | |
} | |
} | |
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = { | |
css: { | |
loaderOptions: { | |
sass: { | |
data: ` | |
$CONDITION: ${process.env.CONDITION || 'false'}; | |
$COLOR: ${process.env.COLOR}; | |
` | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment