add ejs templating and serve coral-admin from /admin

This commit is contained in:
Riley Davis
2016-11-08 11:15:08 -07:00
parent 12aa9c6260
commit a15d2eade7
5 changed files with 10 additions and 21 deletions
+7
View File
@@ -3,11 +3,14 @@ const bodyParser = require('body-parser');
const morgan = require('morgan');
const path = require('path');
const adminConfig = require('./client/coral-admin/config');
const app = express();
// Middleware declarations.
app.use(morgan('dev'));
app.use(bodyParser.json());
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'ejs');
// API Routes.
app.use('/api/v1', require('./routes/api'));
@@ -15,4 +18,8 @@ app.use('/api/v1', require('./routes/api'));
// Static Routes.
app.use('/client/', express.static(path.join(__dirname, 'dist')));
app.get('/admin/*', (req, res) => {
res.render('admin', {basePath: '/client/coral-admin'});
});
module.exports = app;
-10
View File
@@ -1,16 +1,6 @@
const path = require('path')
const fs = require('fs')
const autoprefixer = require('autoprefixer')
const precss = require('precss')
const config = require('./config.json')
// doing a string replace here because I spent a day trying to do it the "webpack" way
// ond nothing works. just trying to replace a string in an index.html file is
// apparently something no one has ever done in the js community.
let templateString = fs.readFileSync(path.join(__dirname, 'index.ejs')).toString()
templateString = templateString.replace('<%= basePath %>', config.basePath)
fs.writeFileSync(path.join(__dirname, 'public/index.html'), templateString)
module.exports = {
entry: {
-9
View File
@@ -1,17 +1,8 @@
const path = require('path')
const fs = require('fs')
const devConfig = require('./webpack.config.dev')
const autoprefixer = require('autoprefixer')
const precss = require('precss')
const Copy = require('copy-webpack-plugin')
const config = require('./config.json')
// doing a string replace here because I spent a day trying to do it the "webpack" way
// ond nothing works. just trying to replace a string in an index.html file is
// apparently something no one has ever done in the js community.
let templateString = fs.readFileSync(path.join(__dirname, 'index.ejs')).toString()
templateString = templateString.replace('<%= basePath %>', config.basePath)
fs.writeFileSync(path.join(__dirname, 'public/index.html'), templateString)
module.exports = Object.assign({}, devConfig, {
module: {
+3 -2
View File
@@ -44,10 +44,11 @@
"dependencies": {
"body-parser": "^1.15.2",
"debug": "^2.2.0",
"ejs": "^2.5.2",
"express": "^4.14.0",
"mongoose": "^4.6.5",
"uuid": "^2.0.3",
"morgan": "^1.7.0"
"morgan": "^1.7.0",
"uuid": "^2.0.3"
},
"devDependencies": {
"babel-core": "6.14.0",