diff --git a/app.js b/app.js index 838819e35..5d91243e8 100644 --- a/app.js +++ b/app.js @@ -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; diff --git a/client/coral-admin/webpack.config.dev.js b/client/coral-admin/webpack.config.dev.js index bd5913b5a..1eba29d66 100644 --- a/client/coral-admin/webpack.config.dev.js +++ b/client/coral-admin/webpack.config.dev.js @@ -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: { diff --git a/client/coral-admin/webpack.config.js b/client/coral-admin/webpack.config.js index 2c81bf4fc..10768b6e5 100644 --- a/client/coral-admin/webpack.config.js +++ b/client/coral-admin/webpack.config.js @@ -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: { diff --git a/package.json b/package.json index 0c7aab592..bbd097221 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/client/coral-admin/index.ejs b/views/admin.ejs similarity index 100% rename from client/coral-admin/index.ejs rename to views/admin.ejs