Giter Club home page Giter Club logo

sass.link.js's Introduction

sass.link.js

Link SCSS stylesheets directly in your browser (compiled via [lib]sass.js)

<link href="example.scss" type="text/scss" />
<style type="text/scss" base="assets/scss">
    @import "style.scss";
</style>
<script src="../dist/sass.link.min.js"></script>

It is basically a mashup of less.js and sass.js. The part to replace all referenced scss stylesheets inside a page has been taken from less.js. The actual compilation is done via sass.js (which is libsass to js via emscripten). Pretty amazing!

Imports within scss

I had to patch the sass.js library to have a hook to load requested files by synchronous XHR. This is expensive, as libsass tries to stat all possible names. There also seems to be a problem when an import path is set (which is preset to /sass/). I saw way too many stat calls so I reset the path to nothing in this implementation.

Compatibility

Tested with the latest versions of Firefox, Chrome, Opera and Internet Explorer. IE 9 and below will not work as it is not possible to compile libsass via emscripten that will still be runnable in IE 9 and below. It will currently error out with this message: "Assertion failed: Cannot fallback to non-typed array case: Code is too specialized".

Demo

Credits

sass.link.js's People

Contributors

mgreter avatar

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.