@ -23,7 +23,6 @@ import webpack from 'webpack';
import webpackDevMiddleware from 'webpack-dev-middleware' ;
import WEBPACK_CONFIG from './webpack.config.js' ;
const compiler = webpack ( WEBPACK_CONFIG ) ;
import express from 'express' ;
@ -50,19 +49,40 @@ async function getHomeView (req, res) {
harness . app . set ( 'view engine' , 'pug' ) ;
harness . app . set ( 'views' , path . join ( __ dirname , 'game' , 'views' ) ) ;
// expose ./game/assets locally as /dist/assets
harness . app . use ( '/dist/assets' , express . static ( path . join ( __ dirname , 'game' , 'assets' ) ) ) ;
/ *
* Nice Game SDK static asset routes are served directly from the
* . / game / assets directory in dev mode .
* /
// expose the local ./platform as /platform to fill in for static assets
// commonly provided by the Nice Arcade platform (shell).
harness . app . use ( '/dist/assets' , express . static ( path . join ( __ dirname , 'game' , 'assets' ) ) ) ;
harness . app . use ( '/platform' , express . static ( path . join ( __ dirname , 'platform' ) ) ) ;
// let Webpack provide /dist with live updates
harness . app . use ( webpackDevMiddleware ( compiler , { publicPath : '/dist' } ) ) ;
/ *
* Webpack integration
* /
// provide the "home" page to serve out the game
harness . compiler = webpack ( WEBPACK_CONFIG ) ;
/ *
* Webpack dev server middleware
* /
harness . webpackDevMiddleware = webpackDevMiddleware ( harness . compiler , {
publicPath : WEBPACK_CONFIG . output . publicPath ,
} ) ;
harness . app . use ( harness . webpackDevMiddleware ) ;
/ *
* This is not a complex web app , it ' s a dev harness that runs a packaged
* application in the browser with live updates . The intent is to provide a
* development harness in which Nice Game SDK games and other apps can be
* built . All this "app" does is serve out the SDK app as if it is being
* loaded in Nice Arcade .
* /
harness . app . get ( '/' , getHomeView ) ;
/ *
* Start the ExpressJS server
* /
const port = parseInt ( process . env . ARCADE_HTTP_PORT || '3000' , 10 ) ;
const host = process . env . ARCADE_HTTP_BIND || '127.0.0.1' ;
console . log ( 'Starting game server harness' , { host , port } ) ;