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

karma-directives-preprocessor

v0.0.5

Published

Karma plugin for preprocessJS: preprocess HTML, Javascript and other files with directives based off custom or ENV configuration

Readme

karma-directives-preprocessor travisci-result

Generate multiple versions of the same file with C-style directives.

Installation

The easiest way is to keep karma-directives-preprocessor as a devDependency in your package.json.

{
  "devDependencies": {
    "karma": "~0.10",
    "karma-directives-preprocessor": "~0.0.1"
  }
}

You can simple do it by:

npm install karma-directives-preprocessor --save-dev

Configuration

Following code shows the default configuration...

// karma.conf.js
module.exports = function(config) {
  config.set({
    files: [
      'src/**/*.js',
      'test/**/*.js'
    ],


    preprocessors: {
      // source files, that you wanna preprocess with directives
      'src/*.js': ['directives']
    },

    directivesPreprocess: {
      flags: {
        'js'  : {development: true, production: false }
      } 
    },

    ...
  });
};

Using this example file, with the configuration above, the code within development flag will be left while the production and test snippets will be removed from the served file.

define([], function () {
  "use strict";

  // @if development
  functionWithDebugOptions();
  // @endif

  // @if production
  superQuickFunction();
  // @endif

  // @ifdef test
  enableThisOtherFunction();
  // @endif

});

Using the include directive you can include your

Supported filetype

Karma-directives is based on preprocess and it does support any filetype.

For each filetype is possible to pass a different set of flags:

directivesPreprocess: {
  flags: {
    'js'  : {flag1: true, flag2: true },
    'html': {flag3: true },
    'css' : {flag4: true }
  } 
},

Contribute

If you want to contribute to the project (e.g. adding new functions, etc..) you're more than welcome. Please add unit tests for any new or changed functionality.

Release history

0.0.5 Added new @include directive 0.0.4 First full documented and tested version.


For more information on Karma see the homepage.