@htmlacademy/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":{}}}

/@htmlacademy/compile-loader/

    Package Sidebar

    Install

    npm i @htmlacademy/compile-loader

    Weekly Downloads

    3

    Version

    1.0.2

    License

    ISC

    Unpacked Size

    2.73 kB

    Total Files

    6

    Last publish

    Collaborators

    • andreychap
    • kaineer
    • nakleikoff
    • expa
    • kam4atka