npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

node-sass-asset-manager

v1.0.7

Published

set of Compass function for node-sass

Downloads

10

Readme

To ease the transitioning from Compass (ruby/gem) to Libsass using Compass Mixins, this module provides some of Compass asset functions for node-sass and two "copy" functions for manage the assets.

NB Please note that the functions option of node-sass is still experimental (>= v3.0.0).

The follow functions are provided:

Installation

npm i -S[-D] node-sass-asset-manager

Configuration

The configuration is optional, but configure the plugin allow the developer to makes less mistakes and write less code.

Webpack config:

const sassAssetManager = require('sass-asset-manager');
 
...

module: {
  rules: [
    {
      test: /\.(css|sass|scss)?$/,
      exclude: [/node_modules/],
      use: [
        'style-loader',
        'css-loader',
        {
          loader: 'sass-loader',
          options: {
            outputStyle: 'compressed',
            functions: assetManager({
                images: {
                  src_root: 'src/assets/imgs/',
                  dest_root: path.resolve(__dirname, '../public/'),
                  path_prefix: '/assets/imgs/',
                  http: 'http://mydomain.com',
                },
                fonts: {
                  src_root: 'src/assets/fonts/',
                  dest_root: path.resolve(__dirname, '../public/'),
                  path_prefix: '/assets/fonts/',
                  http: 'http://mydomain.com',
                },
            }),
            includePaths: [
                path.resolve(__dirname, './node_modules/compass-mixins/lib'),
              ],
          },
      },
      ],
    },
  ],
},

...
  • embed_all if defined all the file described as $src in 'copy' functions will be embedded into the css output, all the other settings will be ignored.
  • src_root path where the images are stored in the source app folder.
  • dest_root path where in the filesystem will be copied the file. If "path_prefix" is defined, will complete the path where the file will be copied.
  • path_prefix it will follow http in the css output path.
  • http If defined it will be the first part in the css output.
source:
.my-class{	
	background-image: copy-image('background.png');
}
result:
.my-class{	
	background-image: url('http://mydomain.com/assets/imgs/background.png');
}

Copy functions

These functions allow the developer to copy the file defined in the first parameter into the path defined in the second one. Both parameters will considerate the preset defined in the plugin configuration.

  • copy-image($src, $dest); This function copy the file described in $src path paramenter in the $dest path paramenter. The $dest paramenter is optional if path_prefix is defined in the plugin configutation and it will be added to this last in the css output if defined. If the path described in $dest starts with ~ the path portion described in path_prefix will be ignored.

  • copy-font($src, $dest, $urlWrap); Same roles like copy-image, just $urlWrap (true by default), have to be turned to false if the function is used inside the font-files function as in the example below. If $dest is not defined because the path used is defined in path_prefix, $urlWrap it can be the second paramenter.

NB. The default font-face compass-mixin retutn a font-url() in the css output intead the standard url() function, so it is better use a custom version of the mixin just before use the functionality as below.

@mixin font-face(
  $name,
  $font-files,
  $eot: false,
  $weight: false,
  $style: false
) {
  $iefont: unquote("#{$eot}?iefix");
  @font-face {
    font-family: quote($name);
    @if $eot {
      src: url($eot);
      $font-files: url($iefont) unquote("format('eot')"), $font-files;
    }
    @if $weight { font-weight: $weight; }
    @if $style { font-style: $style; }
    src: $font-files;
  }
}

@include font-face(
  'MyFontFamily',
  font-files(
    copy-font('MyFont.woff2',false),    /* Super Modern Browsers */
    copy-font('MyFont.woff',false),     /* Pretty Modern Browsers */
    copy-font('MyFont.ttf',false),        /* Safari, Android, iOS */
    copy-font('MyFont.svg#FontName',false)  /* Legacy iOS */
  ),
  copy-font('MyFont.eot',false),        /* IE9 Compat Modes and IE6-IE8 */
  'normal',                             /* font-weight */
  'italic'                              /* font-style */
);