exec-loader

Webpack loader to execute imports at build time.

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
exec-loader
314.0.05 years ago6 years agoMinified + gzip package size for exec-loader in KB

Readme

exec-loader Build Status
Webpack loader to execute imports at build time.
Simply runs the source through this.exec and exports the result.

Installation

npm install --save-dev exec-loader

Usage

latestRevision.js:
var child_process = require('child_process');

module.exports = child_process.execSync('git describe', { encoding: 'utf8' }).trim();

example.js:
import revision from 'exec-loader!./latestRevision';
// revision === 'v1.0.0'

// to cache the result in watch mode
import revision from 'exec-loader?cache!./latestRevision';

// to generate `module.exports` instead of ES6 exports (useful in rare circumstances)
var revision = require('exec-loader?export=commonjs!./latestRevision');