• Stars
    star
    103
  • Rank 333,046 (Top 7 %)
  • Language
    JavaScript
  • Created over 8 years ago
  • Updated about 7 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Webpack 2 / Babel starter kit with full development & build workflow

Webpack Babel Starter

Build Status Release

A webpack 2 starter kit with full development & build workflow, inspired by topheman/react-es6-redux.

What's in this boilerplate:

Already in use in the following projects:

I also have ported it on topheman/angular2-sandbox to be used the same way in an Angular2 / TypeScript project (using v1).

Install

git clone https://github.com/topheman/webpack-babel-starter.git
cd webpack-babel-starter
npm install

Run

npm start

Goto http://localhost:8080

If you need to access from a remote device (such as a smartphone on the same network), just LOCALHOST=false npm start and your site will be accessible via your IP (which will be output on the terminal at launch).

Build

The ./build directory is ignored by git, it will contain a dist directory which holds the distribution version of your website (the one that you will ship once built).

All the build tasks will create a built version of the project in the ./build/dist folder, cleaning it before making the build.

  • npm run build
  • npm run build-prod optimized / uglified version
  • npm run build-prod-all will build:
    • production version (optimized / uglified)
    • a debuggable version accessible at /devtools shipping all the sourcemaps, to ease sharing transpiled source code

npm run serve-dist will serve your ./build/dist folder at http://localhost:3000 so that you could test the built version you just made.

Linter

  • eslint is running while you're developping, check your console for errors
  • you can also launch it via npm run lint
  • see .eslintrc for the configuration (currently, this project uses the airbnb presets - if you find it to restrictive, just remove "extends": "airbnb-base" in the .eslintrc)

Customizations

You can customize the behavior of the scripts by specifying environments vars:

  • NODE_ENV by default at development, NODE_ENV=production when you npm run build-prod
  • LINTER=false will disable the linter (enabled by default, ex: LINTER=false npm start)
  • STATS=true will write stats.json profiling file on disk from webpack at build (disabled by default, ex: STATS=true npm run build)
  • FAIL_ON_ERROR=true will break the build if any errors occurs (useful for CIs such as travis - at false in dev-server, at true when building)
  • LOCALHOST=false to access via IP from other devices on the same network (ex: LOCALHOST=false npm start - default true)
  • DEVTOOLS: By default at null. Used internally by npm run build-prod-all (you may not need that if you don't do OSS)

Assets

The main image loaders are declared in the webpack config so that when you require('./foo.png') or use the helper url('./bar.gif') in your .scss files, at build time, those images will automatically be:

  • copied into /build/dist/assets
  • there name will be hashed (without you bothering with the reference in the generated code)
  • the hashed name will only change if the file changes (caching & git friendly)
  • I made sure that the css supports relative urls (this is why main.css lands at the same level as index.html)

FAQ / Deploy

  • deploy on github pages - see wiki
  • a problem ? Checkout the FAQ
  • Using React ? Checkout how I integrated all the usual tools around React on some of my own projects, based on this boilerplate.

Bonus

Check the source code of the html/js/css generated files, you'll see a banner containing informations such as:

  • date the build was made
  • version
  • git revision / link to this revision on github

Contributing

PRs are welcome, just keep in mind this boilerplate aims to keep beeing framework agnostic.

Everything related to contributing (tests, framework dependencies ...) is located in the /contributing folder. Check the readme in there to see how to setup your workspace.

Versions

v3 (current)

  • Dropped yarn for npm@5 (you remain free to choose whatever package manager you want, the project is compatible with both yarn and npm).

v2

Still available on this branch.

Migrated to webpack2. The workflow and the npm tasks remain exactly the same.

If you were using the v1 with webpack1, the webpack team has a migrating path. You can also see the steps I followed to migrate this stack from v1 to v2:

v1

Still available on this branch.

First version, using webpack1.

Copyright 2017 ยฉ Christophe Rosset

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. The Software is provided "as is", without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose and noninfringement. In no event shall the authors or copyright holders be liable for any claim, damages or other liability, whether in an action of contract, tort or otherwise, arising from, out of or in connection with the software or the use or other dealings in the Software.

More Repositories

1

vanilla-es6-jspm

Seed project for ES6 / jspm based apps with full production workflow
JavaScript
178
star
2

react-es6-redux

A simple app to try React, ES6 and redux, using topheman-apis-proxy as data api backend
JavaScript
156
star
3

npm-registry-browser

Browse the npm registry with an SPA made in React, with full dev workflow.
JavaScript
101
star
4

docker-experiments

Discover docker with a simple use case in development, production (local kubernetes) and CI
JavaScript
96
star
5

topheman-datavisual

Realtime datavisualization with Angular, d3, and nodejs based on Twitter Stream API
JavaScript
77
star
6

twitter-stream-channels

Lets you manage multiple channels of keywords on the same twitter stream
JavaScript
70
star
7

d3-react-experiments

Mix d3 & react
JavaScript
51
star
8

nextjs-movie-browser

A NextJS implementation of the themoviedb.org website
TypeScript
45
star
9

react-es6-isomorphic

A simple app to try React and ES6, using topheman-apis-proxy as data api backend NOW with isomorphism
JavaScript
42
star
10

rxjs-experiments

Playing with RxJS
JavaScript
38
star
11

react-fiber-experiments

Discover the latest features of React fiber like "Suspense"
JavaScript
27
star
12

PanoramaSensorsViewer

Let Google Street View panoramas be browserable via the gyroscope+accelerometer of your mobile device
JavaScript
26
star
13

webassembly-wasi-experiments

Discover WebAssembly System Interface (WASI) with C/Rust use cases
Makefile
24
star
14

rust-wasm-experiments

Discover how to use Rust to generate WebAssembly, called by JavaScript
JavaScript
20
star
15

nextjs-github-browser

Browse github through a website made in NextJS
TypeScript
19
star
16

bevy-rust-wasm-experiments

๐Ÿฆ€ A small video game developed in Rust with Bevy framework targeting both desktop and WebAssembly (browser)
Rust
19
star
17

angular2-sandbox

Mixing Angular2 and RxJS, using @ngrx/store for state management and Webpack for bundling
TypeScript
15
star
18

my-react-app-starter

eslint/prettier/other pre-configured and customisable create-react-app project
JavaScript
11
star
19

Ball.js

Ball.js is a Javascript class that handles physics interactions between balls (i.e. collisions) on a flat area as well as rendering.
JavaScript
10
star
20

webrtc-remote-control

Thin abstraction layer above peerjs that will let you be more productive at making WebRTC data channels based apps.
JavaScript
10
star
21

playground2

An experiment with socket.io and accelerometer (control your desktop with multiple mobile devices)
JavaScript
8
star
22

bombs

HTML5 / Javascript game that takes advantage of the canvas element and the accelerometer on your device.
JavaScript
7
star
23

gopher-ball

Video game made in golang, based on sdl2 bindings
Go
6
star
24

webrtc-experiments

An example of how you could use WebRTC on the web, based on the PeerJS library
JavaScript
5
star
25

sensorsChecker.js

Mostly all recent browsers expose an api for deviceorientation and devicemotion events. This module will let you check if there is really an accelerometer+gyroscope to rely on.
JavaScript
5
star
26

lite-router

A very light router based on history package
JavaScript
4
star
27

squares

An adaptation in HTML5/Javascript - based on the memories I have, of a game I used to play in the 90s on our IIvi (our first color computer).
JavaScript
4
star
28

topheman-apis-proxy

Access your public APIs on the same server, benefite from the existing proxies developed or create yours.
JavaScript
4
star
29

cycle-infos

AngularJS side project made up with the yeoman angular fullstack. Find out the availability of bikes and bike's stands of the JCDecaux self-service bikes
JavaScript
4
star
30

threejs-cone

A little test on threejs ...
JavaScript
3
star
31

BabylonJSFirstSteps

You will find here my first steps on BabylonJS. Those are only tests ...
JavaScript
3
star
32

rustlang-first-try

Starting out in rust
Rust
2
star
33

m102-notes

My general notes taken on the fly while watching the M102 for DBA courses
Shell
2
star
34

Array.foreachLoopBack.js

Loop from any index to any other in your array, looping back at the end of it without bothering about indexes
JavaScript
1
star
35

rust-wasm-examples

JavaScript
1
star
36

my-docker-fullstack-project

1
star
37

SoftLogger

Simple logger that overrides console.log and let's you inject it in a canvas
JavaScript
1
star
38

angular-yeoman-sass-compass

Playing with AngularJS, Yeoman, Grunt, Bower and Karma ...
JavaScript
1
star
39

delay-proxy

Delay specific requests with custom delay - perfect for development
JavaScript
1
star
40

webRtcFirstSteps

JavaScript
1
star
41

HighScoresManager.js

Simlple high scores manager with localStorage
JavaScript
1
star
42

build-free-boilerplate

Simple boilerplate, without any build pipeline, for practice and teaching purpose.
JavaScript
1
star
43

conventional-changelog-angular-loose

conventional-changelog angular config (for those who missed the colon)
JavaScript
1
star