Jonas__G
Jonas__G

Reputation: 185

Buefy not reacting to Sass styling

Beginner here... I've got a simple Vue (2) app and have installed node-sass and sass-loader. Followed the instructions here.

Buefy is imported in main.js and here is the (lower part 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 run serve - and my app works fine - but only has the default Bulma styles. That is - if I add :

<style lang="css">
.somestyle {
 color: red;
}
</style>

... and hit "save" - the app loads with the correct styling. But if I hit refresh in the browser - the custom styling goes away and I'm back to the original Bulma styling. Basically, I can't get the custom scss to "stick".

I've got this working in a different app with (as far as I can see) the exact same settings! This problem is doing my head in :-/

"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 very appreciated!

Upvotes: 0

Views: 572

Answers (1)

Eduardo
Eduardo

Reputation: 1321

I think the problem might be in fact that you didn't connected your variables globally.

https://vue-loader.vuejs.org/guide/pre-processors.html#sharing-global-variables

Here is how I connected Bulma to my Vue project, I think you could use the same pattern while 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";'
      }
    }
  }
}

Upvotes: 1

Related Questions