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: /\.$/ 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/// #else/// #endif /// #if PLATFORM==='pc'/// #elif PLATFORM==='mb'/// #else/// #endif
License
MIT