Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/imcuttle/react-router-ez-loader

react-router-ez-loader
https://github.com/imcuttle/react-router-ez-loader

react-router react-router-ez-loader react-router-v3 webpack-loader

Last synced: about 1 month ago
JSON representation

react-router-ez-loader

Awesome Lists containing this project

README

        

# react-router-ez-loader
[![Build Status](https://travis-ci.org/imcuttle/react-router-ez-loader.svg?branch=master&style=flat-square)](https://travis-ci.org/imcuttle/react-router-ez-loader)
[![NPM version](https://img.shields.io/npm/v/react-router-ez-loader.svg?style=flat-square)](https://www.npmjs.com/package/react-router-ez-loader)
[![NPM Downloads](https://img.shields.io/npm/dm/react-router-ez-loader.svg?style=flat-square&maxAge=43200)](https://www.npmjs.com/package/react-router-ez-loader)

Make your application's react routes code is more ez! :smile:

- Easy to write your routes.js
- Easy to append chunkname for webpack code splitting

## routes.js
```javascript
module.exports = {
path: '/',
component: 'sync!@fe/comps/Layout',
indexRoute: {
component: '@fe/pages/Home'
},
childRoutes: [
{
path: 'edit',
component: '!some-loader!@fe/pages/Edit?n=ABC'
}
]
}
```

## Usage
```javascript
const routes = require('react-router-ez-loader!./routes')
```

## Output
```javascript
module.exports = {
path: '/',
component: require('@fe/comps/Layout').default || require('@fe/comps/Layout'),
indexRoute: {
getComponent: function(location, callback) {
require.ensure([], function() {
callback(null, require('@fe/pages/Home') || require('@fe/pages/Home').default)
}, '@fe/pages/Home')
}
},
childRoutes: [
{
path: 'edit',
getComponent: function(location, callback) {
require.ensure([], function() {
callback(null, require('!some-loader!@fe/pages/Edit') || require('!some-loader!@fe/pages/Edit').default)
}, 'ABC')
}
}
]
}
```