For starters... I have a simple Vue (2) application with node-sass and sass-loader installed. Follow the instructions here.
Buefy is imported into main.js, which is the (bottom half) of (my) App.vue:
<style lang="scss"> // Import Bulma's core @import "~bulma/sass/utilities/_all"; // Set your colors $primary: #8c67ef; $primary-light: findLightColor($primary); $primary-dark: findDarkColor($primary); $primary-invert: findColorInvert($primary); $twitter: #4099FF; $twitter-invert: findColorInvert($twitter); // Lists and maps $custom-colors: null !default; $custom-shades: null !default; // Setup $colors to use as bulma classes (e.g. 'is-twitter') $colors: mergeColorMaps( ( "white": ( $white, $black, ), "black": ( $black, $white, ), "light": ( $light, $light-invert, ), "dark": ( $dark, $dark-invert, ), "primary": ( $primary, $primary-invert, $primary-light, $primary-dark, ), "link": ( $link, $link-invert, $link-light, $link-dark, ), "info": ( $info, $info-invert, $info-light, $info-dark, ), "success": ( $success, $success-invert, $success-light, $success-dark, ), "warning": ( $warning, $warning-invert, $warning-light, $warning-dark, ), "danger": ( $danger, $danger-invert, $danger-light, $danger-dark, ), ), $custom-colors ); // Links $link: $primary; $link-invert: $primary-invert; $link-focus-border: $primary; // Import Bulma and Buefy styles @import "~bulma"; @import "~buefy/src/scss/buefy"; </style>
So I run npm runserve - my app runs fine - but only with the default bulma style. That is - if I add:
<style lang="css"> .somestyle { color: red; } </style>
...Then click "Save" - the app will load with the correct style. However, if I hit refresh in the browser, the custom styles disappear and I'm back to the original Bulma style. Basically, I can't get the custom scss to "stick".
I already use it in another application with (as far as I know) the exact same settings! This question bothers me:-/
"vue": "^2.6.12", "buefy": "^0.9.4", "bulma": "^0.9.3", "node-sass": "^5.0.0", "sass-loader": "^10.1.0"
Not sure what else to include here - but any ideas would be greatly appreciated!
P粉4773692692024-01-29 13:50:15
I think the problem may actually be that you don't have a global connection variable.
https://vue-loader.vuejs .org/guide/pre-processors.html#sharing-global-variables
This is how I connected Bulma
to my Vue
project, I think you can use the same pattern when connecting Buefy
:
// main.ts import '@/assets/scss/main.scss'
// main.scss file @import "~bulma"; @import "./_variables.scss";
// _variables.scss file ...all my sass-variables... @import "~bulma/sass/utilities/_all";
// vue.config.js module.exports = { css: { loaderOptions: { scss: { prependData: '@import "~@/assets/scss/_variables.scss";' } } } }