question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Pass variables to Sass

See original GitHub issue

Hello,

Is it possible to pass any variables to the sass files ?

example:

gulp task:

var gulp = require('gulp');
var $ = require('gulp-load-plugins')();
var sassConfig = require('./config').sass;
var fontsConfig = require('./config').fonts;

gulp.task('sass:dist', function () {
  return gulp.src(sassConfig.mainSassFile)
    .pipe($.sass())
    .pipe($.preprocess({context: {PATH: '../../bower_components/foundation-icon-fonts/icons'}}))
    .pipe($.concat('main.min.css'))
    .pipe($.minifyCss())
    .pipe(gulp.dest(sassConfig.dist.dest));
});

variable sass:

$fi-path: 'PATH';

Thanks for your help

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Reactions:4
  • Comments:6

github_iconTop GitHub Comments

7reactions
kiki-le-singecommented, May 24, 2015

Hello @Keats Thanks for your help. I used the gulp-preprocess package. It allows to do that: .pipe($.preprocess(context: {PATH: ‘…/…/pathIconFontDevEnvironment’}}))

gulp.task('sass:dev', function () {
  return gulp.src('srcPath')
    .pipe($.sass())
    .pipe($.preprocess({context: {PATH: '../../pathIconFontDevEnvironment'}}))
    .pipe(gulp.dest('dirPath'));
});

sass file:

$icon-path: '/* @echo PATH */';
2reactions
sgarbesicommented, Nov 28, 2015

@kiki-le-singe Why would you use preprocess after calling sass()? Shouldn’t it be the other way around?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Variables - Sass
Sass variables are imperative, which means if you use a variable and then change its value, the earlier use will stay the same....
Read more >
Passing values from HTML to SCSS - Stack Overflow
You can pass value from HTML to CSS class using css custom properties (variables). Here is working example : .fill-color { display: block; ......
Read more >
How to Use Mixins in Sass and Pass Arguments – With Code ...
First we define a mixin using the @mixin at-rule. · Then we give it a name – choose whatever you think will fit...
Read more >
Sass - Mixin Arguments - Tutorialspoint
Variable argument is used to pass any number of arguments to mixin. It contains keyword arguments passed to the function or mixin. Keyword...
Read more >
Share variables between JavaScript and CSS
Here are all of the ways I know how to pass data back and forth ... Coupled with Sass variables, it allows you...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found