macro-loader

1.0.0 • Public • Published

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

Readme

Keywords

Package Sidebar

Install

npm i macro-loader

Weekly Downloads

1

Version

1.0.0

License

MIT

Last publish

Collaborators

  • lujiajing1126