Skip to content
Sitepack boilerplate with router5.
JavaScript CSS
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
base
components
config
public
util
webpack
.gitignore
LICENSE
README.md
index.js
package.json

README.md

Sitepack boilerplate with router5

Use router5 as the client side router. Minimal config.

Download

Download from project releases.

Setup

cd router5-boilerplate
npm install

Run development server

Use node-dev to execute the server (more reloading capability, gives less accurate error messages).

npm run dev
open http://localhost:8080

Use Node.js to execute the server (gives more accurate error messages, less reloading capability).

npm run dev:node
open http://localhost:8080

Use npm run dev is fine, switch to npm run dev:node when you encounter weird error messages.

Build

Build your project into ./dist directory.

npm run build

Run production server

Run a static server on ./dist (it will serve ./dist/404.html when request url not found).

npm start
open http://localhost:8080

Guide

Add script/link tags into <head> or <body>

Edit ./base/html.js.

Change default title

Edit ./base/html.js.

Modify layout

Edit ./components/Layout.

Add a new route

  1. Add routes by editing ./config/route.js.
  2. Create route module correspond to route.module you just added.

Get router logs

In ./index.js, uncomment router.usePlugin(Router5.loggerPlugin()).

Add styling loaders/Enable CSS Modules

Edit ./webpack/style-loaders.js.

Add non styling loaders such as babel-lodader, jade-loader

Edit ./webpack/config.{your choice}.js.

Where to put favicon.ico and other resources?

./public.

What happened during build time?

  1. Delete ./dist.
  2. Build bundles, extract styles to {route.name}.css, this also makes route modules able to run in the node context.
  3. Render pages to ./dist/{getRoutePath(route)}/index.html by calling prerender(routeModule).
  4. Build bundles again without extracting styles, optimize for production.
  5. Copy ./public/* into ./dest.
  6. Clean up.
You can’t perform that action at this time.