karma-wrap-preprocessor

Wrap files with a lodash template.

Usage no npm install needed!

<script type="module">
  import karmaWrapPreprocessor from 'https://cdn.skypack.dev/karma-wrap-preprocessor';
</script>

README

karma-wrap-preprocessor Build Status

Wrap files with a lodash template.

Installation

npm install --save-dev karma-wrap-preprocessor

Configuration

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

    preprocessors: {
      'app/**/*.js': ['wrap']
    },

    wrapPreprocessor: {
      // Example: wrap each file in an IIFE
      template: '(function () { <%= contents %> })()',

      // Other options:

      // Use an external template file instead of an inline string:
      file: 'path/to/tpl.txt',

      // Change the variable replaced by file contents (default value is 'contents'):
      variable: 'file',

      // Pass options to lodash template function (see https://lodash.com/docs#template):
      options: {}
    }
  });
};

License

MIT