Macro Loader
A C-style macro pre-processor for webpack
Install
$ npm i macro-loader --save-dev
Usage
In the service layer files, you can easily use C-style macro like following:
// ChoiceItem.jsx#ifdef REACT_NATIVEimport React Component PropTypes from 'react-native'#elseimport React Component PropTypes from 'react'#endif ...
In the configuration for webpack, add this module to preloaders
or loaders
:
...
preLoaders: [
{
test: /\.(js|jsx)$/,
include: srcPath,
loader: 'eslint-loader!macro-loader?config=' + path.join(__dirname,'macros.json')
}
]
...
And add a configuration json file:
//macros.json// or for react-native proj conf
LICENCE
MIT
TODO
The module is still in dev and looking forward for more features