0.0.1 • Published 7 years ago

macro-loader-ex v0.0.1

Weekly downloads
4
License
MIT
Repository
github
Last release
7 years ago

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