Giter VIP home page Giter VIP logo

lib-sass-data-uri's Introduction

This plugin aims to extend lib-sass/node-sass with two functions to convert a file into a data uri and embedd these inside the css. Works gulp-sass package and integrates with jspm.

Installation

var gulp = require('gulp');
var changed = require('gulp-changed');
var sass = require('gulp-sass');
var sassJspm = require('sass-jspm-importer');
var sassDataURI = require('lib-sass-data-uri');

gulp.task('build-css', function() {
  return gulp.src('**/*.scss')
    .pipe(changed('dist/', {extension: '.scss'}))
    .pipe(sass({
      errLogToConsole: true,
      functions: Object.assign(sassDataURI, {other: function() {}})
    }))
    .pipe(gulp.dest('dist/'));
});

Usage

Paths

This plugin supports paths which are relative to the process execution folder and jspm urls which have to be prefixed with jspm:.

Relative: ../some/other/folder/font.woff
JSPM: jspm:font-awesome/fonts/fontawesome-webfont.woff
Functions

data-url($filePath) Converts the file content into a data uri and returns it with wrapping url().

data-uri($filePath) Convertes the file content into a data uri and returns it as string

Example
@font-face {
    font-family: "fontawesome";
    src: url(data-uri('jspm:font-awesome/fonts/fontawesome-webfont.woff!text')) format('woff'),
        data-url('jspm_packages/github/FortAwesome/Font-Awesome/fonts/fontawesome-webfont.woff2') format('woff2'),;
}

Result

@font-face {
    font-family: "fontawesome";
    src: url(data:application/font-woff;base64,<base64EncodedString>) format('woff'),
        url(data:application/font-woff;base64,<base64EncodedString>) format('woff2'),;
}

lib-sass-data-uri's People

Contributors

fragsalat avatar joliss avatar snaptopixel avatar apaleslimghost avatar skotos avatar

Stargazers

Jonathan Stanley avatar Jonathan Rehm avatar

Watchers

James Cloos avatar  avatar

lib-sass-data-uri's Issues

Dart sass compatibility.

As it appears that Dart Sass is becoming the standard, is it possible to make lib-sass-data-uri compiler agnostic? Kind of like gulp-sass is now?

i.e. (for dart):

const sass = require('gulp-sass')(require('sass'));
const sassDataURI = require('lib-sass-data-uri')(require('sass'));

or (for node-sass):

const sass = require('gulp-sass')(require('node-sass'));
const sassDataURI = require('lib-sass-data-uri')(require('node-sass'));

Missing LICENSE file

There doesn't seem to be a license file in this repo. Do you want to add one, like an MIT license?

(I'm OK with my contribution in #3 to be licensed under whatever license you choose.)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.