npm i sass-inline-image
Use the inline-image
function from Compass in node-sass.
// in gulpfile
var gulp = require('gulp');
var sass = require('gulp-sass');
var sassInlineImage = require('sass-inline-image');
gulp.src('style.scss')
.pipe(
sass({
functions: sassInlineImage({ /* options */ })
})
)
.pipe(gulp.dest('./css'));
body {
background: inline-image('path/to/image.png');
}
// In ember-cli-build.js
var EmberApp = require('ember-cli/lib/broccoli/ember-app');
var sassInlineImage = require('sass-inline-image');
module.exports = function(defaults) {
var app = new EmberApp(defaults, {
// Add options here
sassOptions: {
functions: sassInlineImage({ base: 'public/assets/images' })
}
});
return app.toTree();
};
body {
background: inline-image('path/to/figure.svg');
}
Credit to Sergii Iavorskyi at coderwall.
Credit to Joseph Clay for the original implementation.
See license.md.