GithubHelp home page GithubHelp logo

mna / setupjs Goto Github PK

View Code? Open in Web Editor NEW
2.0 2.0 0.0 43 KB

Personal setup for javascript frontend projects.

License: BSD 3-Clause "New" or "Revised" License

Shell 23.16% JavaScript 69.22% CSS 0.36% HTML 7.26%

setupjs's Introduction

Example Setup For Javascript Development

Run npm install in the root directory to install all dependencies. This setup is highly opinionated and personal, YMMV. Hopefully it will stay relevant for a couple weeks. It provides the following:

  • ES2015 support via babel (including polyfill)
  • Type-checking via flow
  • Linting via eslint
  • npm- and browserify-based build system (i.e. no gulp/grunt/etc.)
  • Templating via jade
  • CSS preprocessor via sass
  • Minified production builds for HTML, CSS and JS (via uglifyjs)
  • Separate javascript bundles for dependencies (e.g. babel-polyfill is in a separate file from the app's code)
  • Source maps generated for development build (CSS and JS)
  • Tests via mocha
  • Automatic cache-busting for production build via hashes of content in the filenames
  • Pre-commit hook that checks linting and type-checking errors

Directory Layout

  • / : configuration files
  • /src : the source files
  • /src/styles : the sass files
  • /src/js : the javascript (ES2015 with Flow type annotations) files
  • /src/templates : the jade templates
  • /src/templates/layouts : the layout templates ("master" templates from which pages inherit)
  • /src/templates/includes : includes jade files ("partials")
  • /build : the generated build files, HTML files are directly in this directory
  • /build/js : the generated (ES5, stripped of type annotations) javascript files
  • /build/css : the generated CSS files
  • /scripts : the bash scripts used for the various npm run-script commands
  • /misc : miscellaneous helper files (e.g. git hook)
  • /test : test files, run with npm test
  • /interfaces : flow third-party type definitions
  • /decls : flow type declarations common to the whole project

See the package.json file for the various run-script commands. Most interesting are probably npm run build (set NODE_ENV=production for minified builds), npm run watch and npm run test (or simply npm test).

Editor Support

For vim, install eslint and flow-bin globally and activate as checkers in syntastic to get errors on save. flow is probably too slow for this though.

Installed Libraries

In addition to the development dependencies, this setup installs the following (personal preferences):

  • redux (bundled separately from the app's code)
  • redux-thunk (bundled with redux)
  • deku (bundled separately from the app's code)
  • dscript (generic hyperscript, bundled with deku)
  • bulma (CSS framework)
  • font-awesome (linked from CDN in jade template)

File Sizes

The client-downloaded file sizes are as follows for the production build (minified) and served gzipped:

  • CSS (bulma): 13.1KB
  • babel-polyfill: 34.4KB
  • redux (+redux-thunk): 3.0KB
  • deku (+dscript): 7.6KB

For a total (excluding app's code, style and html) of 58.1KB.

License

The BSD 3-clause license.

setupjs's People

Contributors

mna avatar

Stargazers

 avatar Leonid Shirmanov avatar

Watchers

 avatar James Cloos 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.