Giter VIP home page Giter VIP logo

simple-bundling-js-backend-frontend-boilerplate's Introduction

Simple Bundling JS Server & Web Boilerplate
Compromises:
  • We forgo cache busting via hashing for js as there doesnt seem to be a way to tell parcel to do that if its not handling the html file.
    • Although it is still possible to do it on the server via the ETag
Setup details:
  • Backend uses expressjs for the server
  • The express view engine used is liquid
  • Using nodemon for reloading the server on backend changes
  • Parcel for bundling
    • Parcel also reloads the page on frontend change
    • Parcel also minifies on build
  • concurrently allows us to run all the dev scripts at once in parallel with one command.
  • The run-s in the package.json script is just a shortcut for the npm-run-all program. It runs the npm prod scripts in serial (one after the other).
  • We are using the following babel plugins, presets and macros:
  • We are using flow for type checking on frontend and backend
    • It is set up in the eslint config and also as a npm script to check on build
    • For some reason this file (/node_modules/@parcel/watcher/test/tmp/config.json) breaks flow as it is not proper json, so we have set flow to ignore it in the .flowconfig
    • Parceljs automatically strips the flow typings out
    • In dev, the dev-watch-server npm script runs babel-node via nodemon to strip out the flow typings of the backend code in dev.
    • In prod, we the prod-server-build npm script that just uses babel to strip it out and outputs it to a backend/lib-js. That's why we have the backend/src-js folder and the backend/lib-js folder, so we can keep the same folder structure.
    • Both scripts use the --no-babelrc so it doesnt use the frontend babel config.
  • Using jest for tests
  • We have a js bundle report generated on prod build that opens in the browser
  • We have a flow coverage report generated on prod build that opens in the browser
Additional notes:
  • Can use the dynamic imports to load external libraries after the page has loaded

simple-bundling-js-backend-frontend-boilerplate's People

Contributors

darkle avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.