Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain.Learn More
Socket
Book a DemoInstallSign in
Socket

@node-sass/cdn-importer

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@node-sass/cdn-importer

Node Sass importer for unpkg.com

latest
Source
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

Build Status

cdn-importer

Node Sass importer for resolving from a CDN

Disclaimer

This is ALPHA software.

It's messy. It's probably slow. It's probably buggy.

Give it a shot. File bugs. Be patient.

Support

  • Node >= 6
  • node-sass >= 4.9.0

Install

This package has a peer dependency on Node Sass for ensure import API compatibility.

npm install @node-sass/cdn-importer node-sass

Usage

When Node Sass parses an @import with a URL prefixed by cdn: it will attempt to resolve the URL against following URL. This can be useful for directly consuming files from UNPKG or jsDelivr

@import "cdn:https://unpkg.com/normalize.css@8.0.0/normalize.css";

As a convenience if an @import URL is prefixed by unpgk: the importer will resolve UNPKG short-hand syntax.

@import "unpkg:normalize.css@8.0.0/normalize.css";

Node Sass API

var sass = require('node-sass');
var cdnImporter = require('@node-sass/cdn-importer');

sass.render({
  file: 'index.scss',
  importer: [cdnImporter],
}, function (err, result) {
  if (err) throw err;
  console.log(result.css.toString());
});

Node Sass CLI

$ node-sass index.scss --importer node_modules/@node-sass/cdn-importer/index.js

Caveats

Asynchronous only

Because of how inefficient synchronous network requests are this importer does not work with renderSync.

Single files only

Since @imports in the resolved file won't have the cdn: prefix this impoter is only useful for single file packages like normalize.css

Keywords

node-sass

FAQs

Package last updated on 15 Jul 2018

Did you know?

Socket

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.

Install

Related posts