I have the following folder structure setup:
theme
- assets
- sass
- _theme-styles.scss
- _styles.scss
- modules
- hero
- hero.html
- hero.scss
- hero.css (gulp will compile this file)
_theme-styles.scss is really simple at the moment and looks like this:
// VARS
$white: #FFFFFF;
_styles.scss looks like this:
@import "../../../node_modules/bootstrap/scss/bootstrap.scss";
@import "../../../node_modules/bootstrap/scss/variables.scss";
@import "../../../node_modules/bootstrap/scss/mixins.scss";
$grid-breakpoints: (
xs: 0px,
sm: 576px,
md: 786px,
lg: 992px,
xl: 1200px,
);
// Import Globals
@import "config/**.scss";
And for reference, my gulpfile.js
looks like this:
'use strict';
var gulp = require('gulp');
var sass = require('gulp-sass');
var autoprefixer = require('autoprefixer');
var postcss = require('gulp-postcss');
var paths = {
styles: {
src: 'modules/**/*.scss',
dest: 'modules'
}
}
function scss() {
return gulp.src(paths.styles.src)
.pipe(sass().on('error', sass.logError))
.pipe(sass({ outputStyle: 'compressed' }))
.pipe(postcss([autoprefixer()]))
.pipe(gulp.dest(paths.styles.dest));
}
exports.scss = scss
function watch() {
scss()
gulp.watch(paths.styles.src, scss);
}
exports.watch = watch
What I'm trying to do
I want to reference a variables
and mixins
defined in other files. For example, with my current workflow set as is, in hero.scss I have:
.hero { background: $white; }
I've defined this variable in _theme-styles.scss and want to be able to use it here without redefining.
Similarly, when using mixins, i.e. example below:
.hero{
@include media-breakpointup(md){
padding: 60px;
}
}
The above mixin
is defined in the bootstrap
node module folder. But when referencing these I get undefined errors
when running gulp watch
.