DEV Community

Taylor Beseda
Taylor Beseda

Posted on

2

Bourbon Saas Use Bourbon (Sass) in a Vue CLI Project

First, ensure Sass is installed as a dev dependency (if you didn't select Sass while creating the project with the CLI):

npm install -D sass-loader sass

Install bourbon and bourbon-neat:

npm install -D bourbon bourbon-neat

Configure css.loaderOptions.sass.includePaths to use the correct paths:

//vue.config.js

const bourbon = require('bourbon');
const neat = require('bourbon-neat');

const bourbonPaths = [...bourbon.includePaths, ...neat.includePaths];

module.exports = {
  css: {
    loaderOptions: {
      sass: {
        includePaths: bourbonPaths,
      },
    },
  },
};
Enter fullscreen mode Exit fullscreen mode

Import bourbon and neat (I did this in src/scss/site.scss):

@import '_bourbon'; // leading underscore required*
@import 'neat';
Enter fullscreen mode Exit fullscreen mode

Import site.css in your App:

<template>
  ...
</template>

<style lang="scss">
@import '~@/scss/site';

body {
  background-color: tint(black, 80%); // use a bourbon function
}
.my-container {
  @include grid-container; // use a neat grid
}
</style>
Enter fullscreen mode Exit fullscreen mode

* I don't use Sass enough to understand why the leading underscore is needed. Without it there's a compilation error as it tries to load the bourbon package's main Javascript file instead of the CSS. Any insight would be appreciated.

Sentry image

Hands-on debugging session: instrument, monitor, and fix

Join Lazar for a hands-on session where you’ll build it, break it, debug it, and fix it. You’ll set up Sentry, track errors, use Session Replay and Tracing, and leverage some good ol’ AI to find and fix issues fast.

RSVP here →

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay