0.1.9 • Published 7 years ago

merely v0.1.9

Weekly downloads
-
License
ISC
Repository
-
Last release
7 years ago

Merely

A react/webpack server framework with almost no setup.

Idea

  • Minimal fucking around
  • BYO React
  • ES6, with async/await
  • Server-side rendering
  • Easy async data-fetching for components (even on the server 😍)
  • Support for Redux, React Router and Styled Components
  • Write server code, so that you can implement API endpoints and whatever else you want/need
  • Three simple commands:
    • mere dev — run a hot reloading dev server
    • mere build — build your project, ready for production
    • mere prod — start the production version of your app (run this after mere build!)

Folder structure

Just like a Node.JS app makes use of node_modules and package.json, Merely has three files it'll look for when you run your app.

server.js

This file is automatically required by mere when running your app, both in dev and production modes. The file should export a function, which should at the very least begin listening on a port.

It's also your chance to add any extra request handlers that you might want to add to express! This file will be transformed by Babel, using the same plugins and transforms available for use in client code. This means you can use ES6, JSX, the spread operator and async/await! ✨

module.exports = function(app, isDev) {
  
  // Some kinda cool thing that we might want to use
  app.use('/getCats', (req, res) => {
    res.end(JSON.stringify({
      cats: ["Tuffy", "Maggie", "Pepper"]
    }));
  })
  
  // Listen on port 8080
  app.listen(8080);
  
}

client/main.js

This file shouldn't actually do anything except export some things. Merely handles the boot process for you, so you don't have to worry about initializing React.

Most importantly, you should export your primary application component from this file. It'll be passed a few properties, which you can distribute to child components like React Router and whatever else.

export const App = require('./components/App');