My gulpfile.js contains this:
var elixir = require('laravel-elixir');
elixir(function(mix) {
mix.less(['frontend.less','bootstrap.less','variables.less'],'public/css/frontend.css');
});
frontend.less contains:
#import 'bootstrap.less';
bootstrap.less contains:
#import "variables.less";
#import "../vendor/bootstrap/less/mixins.less";
#import "../vendor/bootstrap/less/normalize.less";
#import "../vendor/bootstrap/less/print.less";
...
Well, the frontend.css depends on
frontend.less
bootstrap.less
variables.less
When I start "gulp watch", it recompiles the frontend.css only when I modify frontend.less, but it should start, too, when I modify one of these files.
I need to define dependencies, but how?
Related
It won't compile it says:
Undefined variable: "$blue-logo-color."
In variables.scss I have:
$blue-logo-color: #3cabf5;
and in site.scss I have:
#import "variables.scss"
.blue-logo-color {
color: $blue-logo-color;
}
.blue-logo-background-color {
background-color: $blue-logo-color;
}
How can I make the WebCompiler include global scss/css files for the compiler? It also doesn't seem to recognize global includes from _Hosts.cshtml.
SCSS import statements require a semicolon
#import "variables.scss";
So basically, I'm trying to modify the button-variant mixin in bootstrap 4. The core file where the code for this resides is bootstrap\scss\mixins, and the filename is _buttons.scss. In my custom.scss, I have the following code:
#import "../../node_modules/bootstrap/scss/bootstrap";
I would want to keep the mixin name the same and not override it using a different name because it's being used in the file node_modules\bootstrap\scss_buttons.scss in the following code that generates all buttons based on the colors available:
#each $color, $value in $theme-colors {
.btn-#{$color} {
#include button-variant($value, $value);
}
}
What happens is that when the new modified mixin code is added below importing bootstrap in custom.scss, it does not have any effect as the imported bootstrap gets compiled after that code and the default button css gets compiled. Whereas, when the modified mixin code is added after importing bootstrap in custom.scss, there is duplication of buttons in the compiled .css file.
How would one go about modifying the code in a mixin without editing the core bootstrap files?
You should import Bootstrap's SCSS files separately instead of the whole pack, and you should import your own mixins after Bootstrap's _mixins.scss. This way you can override them before Bootstrap's _buttons.scss would use them:
#import "bootstrap/scss/functions";
#import "bootstrap/scss/variables";
#import "bootstrap/scss/mixins";
#import "my-custom-mixins";
// rest of Bootstrap imports (see bootstrap.scss):
#import "bootstrap/scss/root";
#import "bootstrap/scss/reboot";
#import "bootstrap/scss/type";
#import "bootstrap/scss/images";
#import "bootstrap/scss/code";
#import "bootstrap/scss/grid";
#import "bootstrap/scss/tables";
#import "bootstrap/scss/forms";
#import "bootstrap/scss/buttons";
#import "my-custom-buttons";
#import "bootstrap/scss/transitions";
#import "bootstrap/scss/dropdown";
#import "bootstrap/scss/button-group";
#import "bootstrap/scss/input-group";
#import "bootstrap/scss/custom-forms";
#import "bootstrap/scss/nav";
#import "bootstrap/scss/navbar";
#import "bootstrap/scss/card";
#import "bootstrap/scss/breadcrumb";
#import "bootstrap/scss/pagination";
#import "bootstrap/scss/badge";
#import "bootstrap/scss/jumbotron";
#import "bootstrap/scss/alert";
#import "bootstrap/scss/progress";
#import "bootstrap/scss/media";
#import "bootstrap/scss/list-group";
#import "bootstrap/scss/close";
#import "bootstrap/scss/toasts";
#import "bootstrap/scss/modal";
#import "bootstrap/scss/tooltip";
#import "bootstrap/scss/popover";
#import "bootstrap/scss/carousel";
#import "bootstrap/scss/spinners";
#import "bootstrap/scss/utilities";
#import "bootstrap/scss/print";
I have the following in my gulpfile.js
var baseDir = 'Base/Assets/scss/**/**';
var modulesDir = 'Modules/**/Assets/scss/*';
return gulp.src([baseDir + '*.scss', modulesDir + '*.scss'])
.pipe(sass({cacheLocation: sassCacheDir, lineNumbers: false}))
.pipe(concat('app.min.css'));
Within the baseDir I have an app.scss file like this:
#import "node_modules/foundation-sites/scss/util/util";
#import "settings";
#import "foundation";
Within the util there's a function called rem-calc. I use this function in my Modules scss files, but these are never executed. Instead in the outputted css I have the following margin-top: rem-calc(10); when this should actually have been converted in to rem's.
The only thing I can thing of is that Gulp isn't remembering the src ordering. Any help will be greatly appreciated.
I have solved this by removing the modulesDir from the gulpfile, instead I'm using a new package called gulp-sass-glob
This allows me to specify the glob in my app.scss file (within baseDir), like this:
#import "node_modules/foundation-sites/scss/util/util";
#import "settings";
#import "foundation";
// now import the modules
#import "../../../../Modules/**/Assets/scss/*.scss";
My gulpfile.js is then like this:
var baseDir = 'Base/Assets/scss/**/**';
gulp.task('site-css', function () {
return gulp.src(baseDir + '*.scss')
.pipe(sassGlob())
.pipe(sass({cacheLocation: sassCacheDir, lineNumbers: false}))
.pipe(concat('app.min.css'));
Hopefully this helps someone else which comes across this scenario.
Here is my _custom.scss:
// Bootstrap overrides
//
// Copy variables from `_variables.scss` to this file to override default values
// without modifying source files.
//$body-bg: $gray-dark;
//$body-color: $gray-light;
$blue: #363636;
$component-active-bg: #484545;
$dropdown-bg: $brand-primary;
$dropdown-link-color: #c3c3c3;
$dropdown-link-hover-color: darken(#c3c3c3, 5%);
and bootstrap.scss:
// Core variables and mixins
#import "variables";
#import "mixins";
#import "_custom";
I am compiling it with the provided Gruntfile.js.
The resultant css file has no effect. Everything looks just like with the original css.
How can I test whether I am getting compilation process actually working?
Thanks
From the format of boostrap.scss I think you should have:
#import "custom";
Next, when you make your changes in _custom.scss, leave off the "!default" tag. For example:
// _variables.css
$blue: #0275d8 !default;
/// _custom.css
$blue: #002b5b;
For example:
main.scss
#import "variables";
#import "page";
_variables.scss
$color-a: #FFFFFF;
_page.scss
div.test {
background: $color-a;
}
Or does variables have to be imported on every sheet that wants to use a variable from it?
Currently, I'm getting Error: Undefined variable: "$color-a"
Edit I should add that I'm using sassc to compile the files in a clojure project:
:sass {:sass-file "main.scss"
:source-maps false
:output-style "compressed"
:output-dir "css/"}}