GraceCovenantChurch / gccweb

Website for GCC
1 stars 1 forks source link

Build improvements #69

Closed austinEng closed 6 years ago

austinEng commented 6 years ago

Please take a good look at this because it's a ton of significant changes...

  1. Server setup has been improved. Instead of two completely separate public and admin servers, there's one shared asset server (but this asset server is only in dev mode. in the future this could be rolled into storing static assets in an s3 bucket or something). The public and admin servers are still separate, but now npm run serve starts them as two separate processes. For our purposes at first, it should be okay to run these both on the same node. It should be portable enough to run on separate nodes if necessary.

  2. CSS loading has been fixed for server builds. The problem was that we had some conflicting names and some css wasn't being loaded because only the css for the Webpack entry points was being loaded (tldr; CSS in dependencies of app.js were not compiled). We are now using CSS Modules, which give us locally namespaced classnames to avoid conflicts and also fixes the CSS dependency problems.

Example:

/* main.css */

.class1 {
  ...
}

.class2 {
  ...
}
// Box.js
import styles from './main.css'

const Box = () => (
  <div className={style.class1}>        {/* This will compile to something like main__class1___alaiw74 */}
     <div className={style.class2} />   {/* main__class2___alsdf3 */}
  </div>
);
  1. On top of that, since we have a better CSS loading system, I've gotten rid of bower and bower_components for downloading stuff like bootstrap and font-awesome. These are instead imported into our CSS builds.

  2. Our formatting checker wasn't checking .jsx files. Now it does, but that means we have hundreds of errors and this won't pass this Travis CI build. We can deal with this later.