1
0
Fork 0
mirror of https://gitlab.com/Alamantus/Readlebee.git synced 2025-06-02 07:30:04 +02:00
Readlebee/app/index.js
Robbie Antenesse 3bfaf5f3df Convert import/export to require/module.exports;Window conditions
Add conditions for whether to use certain things if run from server
2020-09-20 17:19:22 -06:00

43 lines
992 B
JavaScript

require('babel-polyfill');
const choo = require('choo');
const config = require('./config.json');
const { appRoutes } = require('./appRoutes');
const { appListeners } = require('./appListeners');
const { appState } = require('./appState.js');
const { appUtilities } = require('./appUtilities.js');
function frontend() {
const app = choo();
if (process.env.NODE_ENV !== 'production') {
// Only runs in development and will be stripped from production build.
app.use(require('choo-devtools')()); // Exposes `choo` to the console for debugging!
}
app.use((state, emitter) => {
app.siteConfig = config;
appUtilities(app);
});
app.use((state, emitter) => {
appState(app, state);
// Listeners
appListeners(app, state, emitter);
});
// Routes
appRoutes(app);
app.mount('body'); // Overwrite the `<body>` tag with the content of the Choo app
return app;
}
if (typeof window !== 'undefined') {
frontend();
}
module.exports = frontend;