You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
61 lines
1.6 KiB
61 lines
1.6 KiB
// index.js
|
|
// Copyright (C) 2022 Rob Colbert
|
|
// License: Apache-2.0
|
|
|
|
/*
|
|
* This module provides the most basic runtime environment for testing your game
|
|
* in an environment similar to what will be provided when hosted in the arcade.
|
|
*
|
|
* You should not alter this script at all. None of your changes made will be
|
|
* available in the final environment(s).
|
|
*/
|
|
|
|
'use strict';
|
|
|
|
import path, { dirname } from 'path';
|
|
import { fileURLToPath } from 'url';
|
|
const __dirname = dirname(fileURLToPath(import.meta.url)); // jshint ignore:line
|
|
|
|
import { createRequire } from 'module';
|
|
const require = createRequire(import.meta.url); // jshint ignore:line
|
|
|
|
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';
|
|
|
|
const APP_CONFIG = {
|
|
pkg: require('./package.json'),
|
|
};
|
|
|
|
async function getHomeView (req, res) {
|
|
res.locals.gameModuleUrl = '/dist/game-app.bundle.js';
|
|
res.render('game-view');
|
|
}
|
|
|
|
(async ( ) => {
|
|
|
|
const harness = {
|
|
app: express(),
|
|
};
|
|
|
|
harness.app.locals.config = APP_CONFIG;
|
|
harness.app.locals.pkg = APP_CONFIG.pkg;
|
|
|
|
harness.app.set('view engine', 'pug');
|
|
harness.app.set('views', path.join(__dirname, 'game', 'views'));
|
|
|
|
harness.app.use('/dist/assets', express.static(path.join(__dirname, 'game', 'assets')));
|
|
|
|
harness.app.use(webpackDevMiddleware(compiler, { publicPath: '/dist' }));
|
|
|
|
harness.app.get('/', getHomeView);
|
|
|
|
harness.app.listen(3000, ( ) => {
|
|
console.log('CyberEgg 2077 is alive');
|
|
});
|
|
|
|
})();
|