1.0.0 • Published 8 years ago
macro-loader v1.0.0
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_NATIVE
import React, { Component, PropTypes } from 'react-native'
#else
import React, { Component, PropTypes } from 'react'
#endif
class ChoiceItem extends Component {
}
...
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 ["REACT_NATIVE"] for react-native proj conf
LICENCE
MIT
TODO
The module is still in dev and looking forward for more features
1.0.0
8 years ago