vue.js:始终在每个vue样式部分中加载settings.scss文件 [英] vue.js: always load a settings.scss file in every vue style section
问题描述
我发现自己在每个.vue文件中都重复了相同的模式,以便使用变量等:
I find myself repeating this same pattern in every .vue file, in order to use variables, etc.:
<style lang="scss">
@import "../styles/settings.scss";
.someclass { color: $some-variable; }
</style>
或者如果它嵌套在一个文件夹中,我必须记住要小心路径:
or if it's nested in a folder I have to remember to be careful with the path:
<style lang="scss">
@import "../../styles/settings.scss";
</style>
是否可以在我创建的每个.vue文件中全局导入该settings.scss
文件?我看了看文档却没有看到,但是也许我错过了,或者这是我需要利用webpack来做的事情?
Is there a way to globally import that settings.scss
file in every .vue file I create? I looked in the docs and didn't see it, but maybe I missed it, or maybe this is something I need to leverage webpack to do?
推荐答案
The official docs have been updated since I asked this question: https://vue-loader.vuejs.org/en/configurations/pre-processors.html
对于在2017年及以后查看此内容的其他人,请查看加载全局设置文件"下的说明.
For anyone else viewing this in 2017 and beyond, check out the instructions under 'loading a global settings file'.
这篇关于vue.js:始终在每个vue样式部分中加载settings.scss文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!