React and Redux, Webpack 2 boilerplate.
Marvin is internal project by Work & Co. We love React and use it a lot. So Marvin is meant to be a starting point for our React projects. But as we love open source too, it is publicly available for anyone interested in using it.
Name comes from a fictional character Marvin, android from the The Hitchhiker's Guide to the Galaxy book as a homage to it's author Douglas Adams.
- What is this?
- Features
- Setup
- Running in dev mode
- Build (production)
- Running in preview production mode
- Linting
- Git hooks
- Changelog
Boilerplate for kicking off React/Redux applications.
It includes complete, minimal react app. By complete we mean it has examples for:
- components (both container/views and regular ones)
- routes
- reducers (redux)
- actions (both sync and async),
- SASS (with autoprefixer)1
- dummy API
- using assets (in CSS and components)
- imports relative to the app root
1 Using source maps breaks urls in the CSS loader - webpack-contrib/css-loader#232. Try this to fix it (but it breaks testing from local network).
- React
- React router
- Redux
- Redux Thunk
- Redux DevTools (you need to have browser extension installed)
- Immutable reducer data
- Webpack 2 (development and production config)
- Hot Module Replacement
- Babel - static props, decorators
- SASS with autoprefixing
- Webpack dashboard
- Linting
- Included
es6-promise
andisomorphic-fetch
- Preview production build
- File imports relative to the app root
- Git hooks - lint before push
- Tree shaking build
- Switch to redux-saga
- Universal rendering
- Server async data
- Internationalization
Other nice to have features
- Generating
icon font from SVGSVG sprite - Feature detection (Modernizr) (?)
- Google analytics (?)
- Error reporting (?)
Tested with node 6.x and 7.x
$ npm install
$ npm start
Visit http://localhost:3000/
from your browser of choice.
Server is visible from the local network as well.
Running it with webpack dashboard
$ npm run dev
Note for Windows users: webpack dashboard still have issues with Windows, so use npm start
until those are resolved.
OS X Terminal.app users: Make sure that View → Allow Mouse Reporting is enabled, otherwise scrolling through logs and modules won't work. If your version of Terminal.app doesn't have this feature, you may want to check out an alternative such as iTerm2.
Build will be placed in the build
folder.
$ npm run build
If your app is not running on the server root you should change publicPath
at two places.
In webpack.config.js
(ATM line 147):
output: {
path: buildPath,
publicPath: '/your-app/',
filename: 'app-[hash].js',
},
and in source/js/routes
(ATM line 9):
const publicPath = '/your-app/';
Don't forget the trailing slash (/
). In development visit http://localhost:3000/your-app/
.
This command will start webpack dev server, but with NODE_ENV
set to production
.
Everything will be minified and served.
Hot reload will not work, so you need to refresh the page manually after changing the code.
npm run preview
For linting I'm using eslint-config-airbnb, but some options are overridden to my personal preferences.
$ npm run lint
Linting pre-push hook is not enabled by default. It will prevent the push if lint task fails, but you need to add it manually by running:
npm run hook-add
To remove it, run this task:
npm run hook-remove
Add SVG icons to source/assets/icons
folder, and they will automatically be added to SVG sprite.
Usage:
import Icon from 'components/Global/Icon';
<Icon glyph='triangle' />
Available props
glyph // required, name of the SVG icon
className // optional, additional CSS class, default ones are `Icon Icon--iconName`
width // optional, default 24
height // optional, default 24
style // optional, CSS style object
- Added SVG icon loader (SVG sprite) #18
npm start
is not usingwebpack-dashboard
by default cause it still has issues with Windows- Moved
prop-types
fromdevDependencies
todependencies
- Resolved React 15.5 deprecation warnings
- Made sure tree shaking is working
- Removed DevTools from the code, but it still works if you have browser extension
- Fixed duplicating vendor bundle code
- Reduced overall bundle size by disabling
devtool
in production
- Fixed running it on Windows machines
- Updated
webpack
to a stable version
- Added pre-push git hook
- Added
preview
task
- Added Redux Dev Tools.
- Renamed
client
tosource
- Made sure
logger
andDevTools
are loaded only in development
Initial release