Webpack Babel Starter
A webpack starter kit with full development & build workflow, inspired by topheman/react-es6-redux .
What’s in this boilerplate:
- Development / Build / Lint tasks
- Babel transpiler
- Eslint /babel-eslint /eslint-config-airbnb
- Sass support
- Ship a version of your site with sourcemaps (see demo)
git clone https://github.com/topheman/webpack-babel-starter.git cd webpack-babel-starter npm install
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 directory is ignored by git, it will contain a
dist directory which holds the distribution version of your website (the one that you willship 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-prodoptimized / uglified version
npm run build-prod-allwill build:
- production version (optimized / uglified)
- a debuggable version accessible at
/devtoolsshipping 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.
- eslint is running while you’re developping, check your console for errors
- you can also launch it via
npm run lint
.eslintrcfor the configuration (currently, this project usesthe airbnb presets – if you find it to restrictive, just remove
"extends": "airbnb/base"in the
You can customize the behavior of the scripts by specifying environments vars:
NODE_ENVby default at
npm run build-prod
LINTER=falsewill disable the linter (enabled by default, ex:
LINTER=false npm start)
stats.jsonprofiling file on disk from webpack at build (disabled by default, ex:
STATS=true npm run build)
FAIL_ON_ERROR=truewill break the build if any errors occurs (useful for CIs such as travis – at
falsein dev-server, at
LOCALHOST=falseto access via IP from other devices on the same network (ex:
LOCALHOST=false npm start– default
DEVTOOLS: By default at
null. Used internally by
npm run build-prod-all(you may not need that if you don’t do OSS)
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
- 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.csslands at the same level as
FAQ / Deploy
- deploy on github pages -see wiki
- a problem ? Checkout theFAQ
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
- git revision / link to this revision on github
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.
Copyright 2016 © 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.
转载本站任何文章请注明：转载至神刀安全网，谢谢神刀安全网 » Webpack / Babel starter kit with full development & build workflow