[CURRENTLY NOT WORKING] Prelude is an yeoman generator that generates a Rails 5 API-only application with React, Redux, React Redux, React Router and some other stuff all tied nicely by webpack for a webpack + babel all-the-way workflow and a small express server/app to serve an index.html file.
Prelude is an yeoman generator that generates a Rails 5 API-only application with React, Redux, React Redux, React Router, SASS and some other stuff all tied nicely by webpack for a webpack + babel all-the-way workflow and a small express server/app to serve an index.html file.
This is currently in a somewhat alpha stage. There are a lot of loose ends (as you can see in the TO-DO list) and errors may occur. Scrap that, errors will occur.
Update: This commit probably made things more stable.
I’ve been reworking some of the internal stuff here that will check some of those checkboxes on TO-DO and pave the way for the rest. Documentation is still lacking, but if you made your way into this and you don’t want to use the generator directly because of that (or something else), feel free to take a look at the code and steal bits and pieces, everything is MIT. 😁
(This section will be revamped eventually, for now I will just dump the info)
This generator generates an SPA backed by Rails and served with Express.
PORT
env var/api
path to the Rails serverpublic
directory/api
path to the Rails server/assets/bundle.css
webpack-dev-server
in the port 8081/assets
path to the webpack-dev-server
Note: The reason it serves an empty css file in development is because all css
is loaded with style-loader (in development).
style-loader
in development and the excelentExtractTextWebpackPlugin
in productionapp/client/assets
and any requires will return the correct url in both@import
and url()
calls to requires on css filesconfig/webpack.js
-> The main config file. It will seamlessly loadNODE_ENV
varconfig/webpack/development.js
-> Development specific optionsconfig/webpack/production.js
-> Production specific optionsThis is also part of the Webpack configuration.
The project is configured with Hot Module Replacement for faster JS development.
The hot reload will work for both, CSS and JS.
This means that some very cool stuff like this will work out-of-the-box:
And it will also work for CSS (including assets):
yaml-loader
and json-loader
are included and configured so that you can use
the same yaml files for both Javascript and Rails.
To add a new file in a locale, you must add it to the exported object in the
config/locales/<locale>/index.js
file.
import base from './base.yml';
import models from './models.yml';
let en = {
...base.en,
...models.en
};
export { en };
To add a new locale, you must create a new directory in config/locales
with
the name of your locale and inside it put an index.js
like the above.
Then add it to the config/locales/index.js
and export a flatted version of it.
import { en as nestedEn } from './en';
import { pt_BR as nestedPtBR } from './pt-BR';
import flatten from 'flat';
const en = flatten(nestedEn);
const pt_BR = flatten(nestedPtBR);
export { en, pt_BR };
The reason it wasn’t made in a way that could just work is that javascript’s
new import statements are made to be static. If you want to
make it more automatic, you can use something like
glob-loader with a normal require.
Automatically included and configured:
/app
to make sure it won’t collide with anyLink
components asFirst, install Yeoman and generator-prelude using npm (assuming you have node.js installed).
npm install -g yo
npm install -g generator-prelude
Then generate your new project:
yo prelude project-name
MIT © Mateus "Doodad" Medeiros