0.1.3 • Published 7 years ago

routes-loader v0.1.3

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

Routes Loader

Webpack loader to transform a directory of files to a routes object.

Setup

The base directory must have an index file.

Any file named '_layout' will be treated as a layout component for all routes in the same directory.

Any route named '404' will have a path of '*'

Automatically generate react-router route components

import routes from 'routes!./pages'

render((
  <Router history={browserHistory} routes={routes} />
), document.getElementById('react'))

Each route component will be loaded with require.ensure for code splitting with zero configuration

Import a list of routes and their corresponding files

import routeList from 'routes?list!./pages'

routeList.forEach(route => renderToHtml(route.path))

This is useful for pre-rendering pages and generating a sitemap.

Load the raw route hierarchy

import genericRoutes from 'routes?raw!./pages'

myCustomRouter.use(genericRoutes)
0.1.3

7 years ago

0.1.2

8 years ago

0.1.1

8 years ago

0.1.0

8 years ago

0.0.3

8 years ago

0.0.2

8 years ago

0.0.1

8 years ago