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

sass-import-compiler

v0.0.4

Published

accepts an array of scss files and writes them to @imports for a main scss file

Downloads

9

Readme

sass import compiler

This plugin is for developers who use the watch contrib to compile their scss on file updates. It allows you to manage your main scss file @import's in a config array in your gruntfile. This way you do not have to do the duplicitive work of managing an array of scss files to watch and updating a list of files to import in your primary scss file.

At it's simplest this plugin takes an array of scss files like this:

[
	'file-one.scss',
	'file-two.scss',
	'file-three.scss'
]

And writes an scss file that looks like this:

@import 'file-one';
@import 'file-two';
@import 'file-three';

Getting Started

This plugin requires Grunt.

If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:

npm install sass-import-compiler --save-dev

Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:

grunt.loadNpmTasks('sass-import-compiler');

The "sass_import_compiler" task

Overview

In your project's Gruntfile, add a section named sass_import_compiler to the data object passed into grunt.initConfig().

grunt.initConfig({
  sass_import_compiler: {
    your_target: {
      // Target-specific file lists and/or options go here.
    },
  },
})

Options

keepExtensions

Type: Boolean Default: false

If set to true .scss file extensions will not be removed from paths when writing them to them in the destination file.

Usage Examples

Basic Setup

In this example, src/main.scss will be written to contain the three files below as @import partials.

grunt.initConfig({
  sass_import_compiler: {
    files: {
      'src/main.scss': ['src/vars.scss', 'src/mixins.scss', 'src/header.scss'],
    }
  }
})

For this configuration, the contents of src/main.scss will be:

@import 'src/vars';
@import 'src/mixins';
@import 'src/header';

With Watch

I created this plugin with the idea of using it in tandem with the grunt watch contrib. The thought being that you maintain your scss dependencies in an array outside the grunt config, and then only have to maintain them in one place. You use watch to compile on any file updates and you use watch to monitor any change to your configuration and re-compile your scss @import list on your main file.

First you would have to manage your scss dependencies in a seperate array. This could be before your grunt.initConfig in gruntfile.js or in a seperate config file you require.

var scss_dependencies = [
		'src/vars.scss',
		'src/mixins.scss',
		'src/header.scss'
	];

Then set up your grunt config so the sass plugin compiles from your sass_import_compiler destination file. Set up watch to run the sass task to any update to a file in scss_dependencies, and to run the sass_import_comiler task whenever the file containing scss_dependencies updates (in this case we'll assume it's managed in gruntfile.js).

grunt.initConfig({
  sass_import_compiler: {
  	src: {
  	  files: {
        'src/main.scss': scss_dependencies
      }
  	}
  },
  sass: {
    dist: {
  	  files: {
  	    'dist/main.scss': 'src/main.scss'
  	  }
    }
  },
  watch: {
    gruntfile: {
      options: {
        reload: true,
        atBegin: true
      },
      files: [
        'gruntfile.js'
      ],
      tasks: [
        'sass_import_compiler:src',
        'sass:dist'
      ]
    },
    sass: {
    	files: scss_dependencies,
    	tasks: [
    		'sass:dist'
    	]
    }
  }
})

License

Copyright (c) 2014 Justin Worsdale. Licensed under the MIT license.