Easily structure your Sass

Easily structure your Sass

ยท

2 min read

Hello everyone ๐Ÿ‘‹,

Intro

A year ago, I published an NPM package to generate a Sass file structure at the root of a project.

The goal behind this idea was to help our dev team to have "one source of truth" regarding the way we organized our code. And it worked well at first. We all used it, to start a new project, and it became more maintainable.

But there was one big issue that we could not solve with this package, it was not flexible enough.

Because not all projects are the same, having to use the same template for all our projects was not ideal.

The solution: create a CLI to give more options to the devs, like choosing the path of installation, multiple templates, "helper" code, etc.

The CLI

create-scss-cli setup example

The CLI generates a Sass file structure based on the 7-1 pattern. You can choose where you want to install it into your project. It comes with (variables, mixins, functions, and maps to generate helper CSS classes).

If you only want to file structure, but without any code, you can select the "clean" template. It will generate all the files, without any starter code.

Otherwise, you also have the option to remove the specific folder from the structure. Don't need a vendor or theme folder, no problem, simply select which folder you want to discard from the original structure.

Structure

scss
    โ”‚
    โ”œโ”€โ”€ abstracts
    โ”‚   โ”œโ”€โ”€ colors
    โ”‚   โ”œโ”€โ”€ fonts
    โ”‚   โ”œโ”€โ”€ index
    โ”‚   โ”œโ”€โ”€ mixins
    โ”‚   โ”œโ”€โ”€ spacing
    โ”‚   โ””โ”€โ”€ helper
    โ”‚
    โ”œโ”€โ”€ base
    โ”‚   โ”œโ”€โ”€ global.scss
    โ”‚   โ”œโ”€โ”€ shame.scss
    โ”‚   โ””โ”€โ”€ typography.scss
    โ”‚
    โ”œโ”€โ”€ components
    โ”‚   โ”œโ”€โ”€ alert.scss
    โ”‚   โ”œโ”€โ”€ banner.scss
    โ”‚   โ”œโ”€โ”€ buttons.scss
    โ”‚   โ”œโ”€โ”€ card.scss
    โ”‚   โ”œโ”€โ”€ forms.scss
    โ”‚   โ”œโ”€โ”€ icons.scss
    โ”‚   โ”œโ”€โ”€ menu.scss
    โ”‚   โ”œโ”€โ”€ modal.scss
    โ”‚   โ”œโ”€โ”€ progress.scss
    โ”‚   โ””โ”€โ”€ table.scss
    โ”‚
    โ”œโ”€โ”€ layout
    โ”‚   โ”œโ”€โ”€ footer.scss
    โ”‚   โ”œโ”€โ”€ grid.scss
    โ”‚   โ”œโ”€โ”€ header.scss
    โ”‚   โ”œโ”€โ”€ navigation.scss
    โ”‚   โ””โ”€โ”€ sidebar.scss
    โ”‚
    โ”œโ”€โ”€ pages
    โ”‚   โ””โ”€โ”€ home.scss
    โ”‚
    โ”œโ”€โ”€ themes
    โ”‚   โ””โ”€โ”€ dark.scss
    โ”‚
    โ”œโ”€โ”€ vendor
    โ”‚   โ””โ”€โ”€ normalize.scss
    โ”‚
    โ””โ”€โ”€ main.scss

Installation

Prerequisites

You can install the package globally or execute it right away with npx.

Global install

npm i -g create-scss-cli

After that, you'll be able to use the create-scss-cli command in your project like so:

cs-cli

NPX

npx create-scss-cli

Documentation

๐Ÿ‘‰ createscss.com
๐Ÿ‘‰ github.com/maximedaraize/create-scss-cli
๐Ÿ‘‰ npmjs.com/package/create-scss-cli

Conclusion

I would really appreciate any feedback. This is a side-project but I have the intention to keep working on it. Contribution is welcome ๐Ÿค™

Thanks for reading,

Max

ย