compile-loader

1.0.2 • Public • Published

compile-loader

Allows custom preprocessing by evaluating the module at compile time.

Useful for removing secrets from the source when bundling config files.

Installation

npm install compile-loader --save-dev

Example

function PRIVATE(a) {
  return process.env.CLIENT ? a : undefined;
}
module.exports = {
  production: {
    port: 9000,
    assets: [],
    session: {
      secret: PRIVATE('eE79c5!637304*34eA0d5f5fbb,e3d1?')
    }
  }
};

Without the loader, calling PRIVATE will not change the behavior of the above code.

However, when using the eval-loader, webpack will evaluate the module at compile time and replace its contents with the resulting value of module.exports.

// resulting webpack bundle
module.exports = {"production":{"port":9000,"assets":[],"session":{}}}

Dependencies (0)

    Dev Dependencies (0)

      Package Sidebar

      Install

      npm i compile-loader

      Weekly Downloads

      3

      Version

      1.0.2

      License

      ISC

      Last publish

      Collaborators

      • levjj