@@ -5,7 +5,7 @@ import express from 'express';
55import webpack from 'webpack' ;
66import devMiddleware from 'webpack-dev-middleware' ;
77import hotMiddleware from 'webpack-hot-middleware' ;
8- import fs from 'fs' ;
8+ import fs from 'fs-extra ' ;
99import path from 'path' ;
1010import watch from 'node-watch' ;
1111import buildEntry from './buildEntry' ;
@@ -48,6 +48,7 @@ const stringifyData = data => `module.exports = [
4848]` ;
4949
5050export function build ( {
51+ assets,
5152 pages : getPages ,
5253 output,
5354 layout = require . resolve ( './templates/Layout' ) ,
@@ -61,6 +62,7 @@ export function build({
6162
6263 fs . writeFileSync ( path . join ( output , 'app.src.js' ) , buildEntry ( { layout } ) ) ;
6364 fs . writeFileSync ( path . join ( output , 'app.data.js' ) , stringifyData ( data ) ) ;
65+ fs . copySync ( assets , path . join ( output , 'assets' ) ) ;
6466
6567 buildEntry ( { layout } ) ;
6668 buildPageInfo ( data ) . forEach ( info => {
@@ -90,6 +92,7 @@ export function build({
9092}
9193
9294export function serve ( {
95+ assets,
9396 pages : getPages ,
9497 output,
9598 port = 3031 ,
@@ -137,6 +140,10 @@ export function serve({
137140
138141 const app = express ( ) ;
139142
143+ app . get ( '/assets/*' , ( req , res ) => {
144+ res . sendFile ( path . join ( assets , req . path . replace ( / ^ \/ a s s e t s \/ / , '' ) ) ) ;
145+ } ) ;
146+
140147 app . get ( '*' , ( req , res , next ) => {
141148 const page = req . path . slice ( 1 ) . replace ( / \. h t m l $ / , '' ) ;
142149
0 commit comments