Skip to content

matthisk/es6console

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

ES6Console.com

This is the main repository of es6console.com. A tool for playing around with ECMAScript 6 to 5 transformers.

Table of Contents

  1. Features
  2. Requirements
  3. Application Structure
  4. Development
  5. Developer Tools
  6. Routing
  7. Testing
  8. Deployment
  9. Build System
  10. Configuration
  11. Globals
  12. Styles
  13. Server
  14. Production Optimization

Features

Requirements

  • node ^4.5.0
  • yarn ^0.17.0 or npm ^3.0.0

Install from source

First, clone the project:

$ git clone https://github.com/matthisk/es6console.git <my-project-name>
$ cd <my-project-name>

Then install dependencies and check to see it works. It is recommended that you use Yarn for deterministic installs, but npm install will work just as well.

$ npm install    # Install project dependencies
$ npm run dev      # Compile and launch (same as `npm start`)

While developing, you will probably rely mostly on npm dev; however, there are additional scripts at your disposal:

npm run <script> Description
start Serves your app at localhost:8000. HMR will be enabled in development.
compile Compiles the application to disk (~/dist by default).
dev Same as npm start, but enables nodemon for the server as well.
test Runs unit tests with Karma and generates a coverage report.
test:dev Runs Karma and watches for changes to re-run tests; does not generate coverage reports.
deploy Runs linter, tests, and then, on success, compiles your application to disk.
deploy:staging Same as deploy but overrides NODE_ENV to "development".
deploy:prod Same as deploy but overrides NODE_ENV to "production".
deploy_lambda Same as deploy_lambda but overrides NODE_ENV to "production".
deploy_lambda:staging Same as deploy_lambda but overrides NODE_ENV to "production".
deploy_lambda:prod Same as deploy_lambda but overrides NODE_ENV to "production".
lint Lint all .js files.
lint:fix Lint and fix all .js files. Read more on this.

Application Structure

.
โ”œโ”€โ”€ bin                      # Build/Start scripts
โ”œโ”€โ”€ config                   # Project and build configurations
โ”œโ”€โ”€ public                   # Static public assets (not imported anywhere in source code)
โ”œโ”€โ”€ server                   # Express application that provides webpack middleware
โ”‚   โ””โ”€โ”€ main.js              # Development Server application entry point
โ”œโ”€โ”€ src                      # Application source code
โ”‚   โ”œโ”€โ”€ index.html           # Main HTML page container for app
โ”‚   โ”œโ”€โ”€ main.js              # Application bootstrap and rendering
โ”‚   โ”œโ”€โ”€ components           # Global Reusable Presentational Components
โ”‚   โ”œโ”€โ”€ containers           # Global Reusable Container Components
โ”‚   โ”œโ”€โ”€ layouts              # Components that dictate major page structure
โ”‚   โ”‚   โ””โ”€โ”€ CoreLayout.js    # CoreLayout which receives children for each route
โ”‚   โ”‚   โ””โ”€โ”€ CoreLayout.scss  # Styles related to the CoreLayout
โ”‚   โ”‚   โ””โ”€โ”€ index.js         # Main file for layout
โ”‚   โ”œโ”€โ”€ routes               # Main route definitions and async split points
โ”‚   โ”‚   โ”œโ”€โ”€ index.js         # Bootstrap main application routes with store
โ”‚   โ”‚   โ”œโ”€โ”€ Home             # Fractal route
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ index.js     # Route definitions and async split points
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ assets       # Assets required to render components
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ components   # Presentational React Components
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ routes **    # Fractal sub-routes (** optional)
โ”‚   โ”œโ”€โ”€ store                # Redux-specific pieces
โ”‚   โ”‚   โ”œโ”€โ”€ createStore.js   # Create and instrument redux store
โ”‚   โ”‚   โ””โ”€โ”€ reducers.js      # Reducer registry and injection
โ”‚   โ””โ”€โ”€ styles               # Application-wide styles (generally settings)
โ”œโ”€โ”€ lambda                   # AWS Lambdas
โ””โ”€โ”€ tests                    # Unit tests

Development

Developer Tools

Testing

To add a unit test, simply create a .spec.js file anywhere in ~/tests. Karma will pick up on these files automatically, and Mocha and Chai will be available within your test without the need to import them. Coverage reports will be compiled to ~/coverage by default. If you wish to change what reporters are used and where reports are compiled, you can do so by modifying coverage_reporters in ~/config/project.config.js.

Deployment

ES6Console is hosted on Amazon S3. When running npm run deploy the ~/dist folder is synced up to the s3 bucket configured in config/environment.config.js. The website requires several backend scripts which are hosted on AWS Lambda using the serverless framework. When running npm run deploy_lambda these lambdas are automatically deployed.

Configuration

Default project configuration can be found in ~/config/project.config.js. Here you'll be able to redefine your src and dist directories, adjust compilation settings, tweak your vendor dependencies, and more. For the most part, you should be able to make changes in here without ever having to touch the actual webpack build configuration.

If you need environment-specific overrides (useful for dynamically setting API endpoints, for example), you can edit ~/config/environments.config.js and define overrides on a per-NODE_ENV basis. There are examples for both development and production, so use those as guidelines. Here are some common configuration options:

Key Description
dir_src application source code base path
dir_dist path to build compiled application to
server_host hostname for the Express server
server_port port for the Express server
compiler_devtool what type of source-maps to generate (set to false/null to disable)
compiler_vendor packages to separate into to the vendor bundle

Webpack is configured to make use of resolve.root, which lets you import local packages as if you were traversing from the root of your ~/src directory. Here's an example:

// current file: ~/src/views/some/nested/View.js
// What used to be this:
import SomeComponent from '../../../components/SomeComponent'

// Can now be this:
import SomeComponent from 'components/SomeComponent' // Hooray!

Globals

These are global variables available to you anywhere in your source code. If you wish to modify them, they can be found as the globals key in ~/config/project.config.js. When adding new globals, make sure you also add them to ~/.eslintrc.

Variable Description
process.env.NODE_ENV the active NODE_ENV when the build started
__DEV__ True when process.env.NODE_ENV is development
__PROD__ True when process.env.NODE_ENV is production
__TEST__ True when process.env.NODE_ENV is test

Styles

Both .scss and .css file extensions are supported out of the box. After being imported, styles will be processed with PostCSS for minification and autoprefixing, and will be extracted to a .css file during production builds.

Production Optimization

Babel is configured to use babel-plugin-transform-runtime so transforms aren't inlined. In production, webpack will extract styles to a .css file, minify your JavaScript, and perform additional optimizations such as module deduplication.