![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
gulp-inject-scss
Advanced tools
Transpile Javascript variables into SCSS variables during the pipe task.
Inject Javascript arrays to render SCSS variables or imports during a pipe task.
Basically the same principle as Postilabs Inject SCSS page, only this variation works within streams/pipes. So you can inject variables or imports directly before your SCSS compilation.
So you could use this to respect environment paths that differ between development and production servers for example. Or keep unit sizes consistent between Javascript and CSS. Or maybe you just need to define a special custom property bespoke to your needs.
npm i gulp-inject-scss --save
const injectScss = require('gulp-inject-scss')
Pass an associative array where the keys are the css properties and the values are the css values.
gulp.task('sass', () => {
let variables = {
'images':'"../assets/images/"',
'max-height':'100vh',
'browser-version':11
}
return gulp.src(config.sources.sass)
.pipe(injectScss(variables))
.pipe(gulpsass({outputStyle: 'compressed'}))
.pipe(gulp.dest("cssfile.css"))
});
:root { --browser-version : #{$browser-version}; }
body {
background-image:url(#{$images} + 'wallpaper.jpg');
max-height:#{$max-height};
}
:root { --browser-version : 11; }
body {
background-image:url(../assets/images/wallpaper.jpg);
max-height:100vh;
}
You can also pass in nested objects, which will resolve to a Sass Map.
let variables = {
'images':'"../assets/images/"',
'max-height':'100vh',
'browser-version':11,
'themes' : {
'primary' : '#FFF8DC',
'secondary' : '#EFF0F1'
}
}
The following won't actually be rendered anywhere for you to see. It's done entirely dynamically. This is just an idea of what becomes available to you within your scss development.
$themes : (
primary : '#FFF8DC',
secondary : '#EFF0F1'
);
Pass an array of strings and render each one as an css @import.
gulp.task('sass', () => {
let imports = {
'vendor/marknotton/doggistyle/dist/_doggistyle.scss',
'settings/_symbols.scss'
}
return gulp.src(config.sources.sass)
.pipe(injectScss(imports))
.pipe(gulpsass({outputStyle: 'compressed'}))
.pipe(gulp.dest("cssfile.css"))
});
The following won't actually be rendered anywhere for you to see. It's done entirely dynamically. This is just an idea of what becomes available to you within your scss development.
@import 'vendor/marknotton/doggistyle/dist/_doggistyle';
@import 'settings/_symbols.scss';
To use both injection methods, you can simply include both array types in any order.
.pipe(injectScss(imports, variables))
FAQs
Transpile Javascript variables into SCSS variables during the pipe task.
We found that gulp-inject-scss demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.