webpack-define-loader

A c style conditional compilation webpack loader

Showing:

Popularity

Downloads/wk

3

GitHub Stars

3

Maintenance

Last Commit

4yrs ago

Contributors

0

Package

Dependencies

1

Size (min+gzip)

23.2KB

License

MIT

Type Definitions

Tree-Shakeable

No?

Categories

Readme

Webpack-Define-Loader

this loader can provide your code(js/ts/...) the ability of c style conditional compilation

Installation

this loader requires node version >= 4

  • npm
npm install webpack-define-loader --save-dev
  • or use yarn
yarn add webpack-define-loader --dev

Example:

//webpack2 config
{
    //...
    module: {
        rules: [
            test: /\.(js|jsx|vue)$/,
            loader: 'webpack-define-loader',
            options: {
                DEBUG: true,
                PLATFORM: 'pc'
            },
            enforce: 'pre',
            exclude: /node_modules/
        ]
    }
    //...
}

/*
 * code file
 * conditional compilation begin with `///`
 * condition after #if and #elif directive can be any legal js expression
 */

/// #if DEBUG
import parse from './parse.debug'
/// #else
import parse from './parse.release'
/// #endif

/// #if PLATFORM==='pc'
import render from './render.pc'
/// #elif PLATFORM==='mb'
import render from './render.mb'
/// #else
import render from './render.common'
/// #endif

License

MIT

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100