SCSS & Gulp.js
Canvas ships with a full SCSS source and a Gulp.js build pipeline so you can customize the styles cleanly and compile production-ready assets. Writing your styles in SCSS keeps them organized and maintainable, while Gulp automates the repetitive tasks: compiling SCSS to CSS, adding vendor prefixes, generating RTL stylesheets, bundling and minifying JavaScript, and optimizing images.
You only need the build tools if you want to compile from source. If you are editing the static HTML files directly, you can skip Gulp entirely and just edit style.css or add your overrides to css/custom.css.
How to Use
- 1
Editing the SCSS
The master file is
style.scssin the root of theHTMLfolder. It imports all of the partials from thesass/folder (for examplesass/_header.scss,sass/_typography.scss,sass/shortcodes/).Customize colors, fonts, and spacing from the two variable files:
sass/_variables.scss- Canvas variables (brand colors, fonts, etc.)sass/bootstrap/_variables.scss- Bootstrap variables
Add your own rules in a new partial or in
sass/_extras.scss, then recompile so the changes land instyle.css. - 2
Installing the build tools
Compiling from source uses Node.js and Gulp. Canvas 8 requires Node.js 20.19.0 or newer (check with
node -v).Open a terminal (VS Code's built-in terminal works well),
cdinto your project folder, and install the dependencies listed inpackage.json:cd /path/to/canvas/HTML npm installThis installs Gulp and all the build plugins locally. You do not need to install Gulp globally; run tasks with
npx gulp <task>(or addnode_modules/.binto your PATH). - 3
Running the Gulp tasks
The tasks defined in
gulpfile.jsare:npx gulp watch- Starts a BrowserSync live-reload server, watches your.scss,.html, andjs/files, and recompilesstyle.scsstostyle.css(plusstyle-rtl.css) on every save. Use this while developing.npx gulp scsscompile- Compilesstyle.scsstostyle.cssand generates the RTL stylesheetstyle-rtl.cssonce.npx gulp rtl- Generatesstyle-rtl.cssfrom the currentstyle.css.npx gulp buildjs- Concatenates and minifies the plugins and functions into the bundles underdist/js.npx gulp jsminify- Minifies the JavaScript injs/todist/js.npx gulp cssminify- Minifies every CSS file to thedist/folder.npx gulp htmlminify- Minifies the HTML pages intodist/.npx gulp imageminify- Compresses all images and writes the optimized copies todist/.npx gulp minify- Runs bothcssminifyandjsminify.npx gulp demosrtl- Builds RTL versions of the demo stylesheets intodist/demos.
- 4
Finalizing for production
For a production upload, run the minify tasks to generate optimized assets in the
dist/folder, then point your pages at those minified files. Thedist/folder mirrors the source structure (dist/js,dist/demos, minified CSS), so you can upload the optimized versions in place of the development files.
