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 🙏

© 2026 – Pkg Stats / Ryan Hefner

grunt-at-imports

v2.0.3

Published

A grunt task to create import statements from a collection of stylesheet files

Readme

grunt-at-imports

A grunt task to create one file with import statements from a collection of stylesheet files. This is an adaption of the already existing npm plugin grunt-less-imports which only supports .less files.

LessCSS

@import (once) "filename"; // <-- these. in one file.

SASS/SCSS

@import "filename"; // <-- these. in one file.

Javascript

import "filename"; // <-- these. in one file.

Why use this? To get useful error messages from the parser, that tell you in what file the error was encountered! The parser uses import statements to aggregate files and will tell you about parsing errors in those files. But maintaining these statements by hand is a pain. In order to automatically aggregate all the style files in a project, a method of first concatenating the files before parsing is widely used. This works but you loose the valuable information about where to fix your mistakes.

So, automate import creation with this plugin and use the resulting file as the source for the parser.

By default any .css source files are inlined in the output before the import statements for the less files start.

Getting Started

This plugin requires Grunt ^0.4.5

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 grunt-at-imports --save-dev

--save-dev adds the plugin to your devDependencies.

Once the plugin has been installed, load it in your Gruntfile.js like so:

grunt.loadNpmTasks('grunt-at-imports');

The "at_imports" task

Overview

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

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

Options

  • options.inlineCSS {Boolean} true

    By default any .css source files are inlined in the output before the @import statements for the files start. The parser itself will generate CSS from @import statements, but any .css imports are left as is. If that's the behavior you want, set inlineCSS to false. The imports will be created in order of the provided files.

  • options.banner {String} "// This file was generated by grunt-at-imports"

    This option contains the banner that is added to the beginning of the generated output file.

  • options.import {String|Function} "once"

    Set Less import option keyword. Only applies if the output file extension is .less. String: Set the keyword for all @import statements in the task target. Function: Dynamically set the @import keyword with a callback. The path and extension of the current file are passed as arguments. The function must return a string.

Examples

Basic example with options

grunt.initConfig({
	at_imports: {
		options: {
			inlineCSS: false, // default: true
			import: 'reference' // default: once
		},
		src: [ 'styles/*.css', 'styles/*.less'],
		dest: 'temp/imports.less'
	}
})

More Examples

Using 'files' shorthand notation

In this example, a files shorthand is used to specify input files and the output file instead of src and dest.

grunt.initConfig({
	at_imports: {
		options: {
		},
		files: {
			'dist/imports.scss': ['styles/styles.css', 'styles/styles.scss']
		}
	}
})

Using multiple task targets

grunt.initConfig({
	at_imports: {
		options: { // general task options
			inlineCSS: false
		},
		project: {
			src: [ 'styles/*.css', 'styles/*.less'],
			dest: 'dist/project.less'
		},
		vendor: {
			options: { // target-specific options
				import: 'reference'
			},
			src: [ 'styles/vendor/*.css', 'styles/vendor/*.less'],
			dest: 'dist/vendor.less'
		}
	}
})

Example with a options.import callback

grunt.initConfig({
	at_imports: {
		options: {
			import: function(filepath, extension) {
				if (filepath === 'styles/helpers.less')
					return 'reference';
				else
					return 'once';
			}
		},
		src: [ 'styles/*.css', 'styles/*.scss'],
		dest: 'temp/imports.scss'
	}
})

Troubleshooting

Warning: Arguments to path.join must be strings

Most likely caused by a change in Node 0.10.0. Fixed in Grunt 0.4.1. Update grunt and grunt-cli.

Contributing

How to contribute to a project on Github

Release History

see CHANGELOG.md