ManuelDeLeon/viewmodel-react-starter

Starter project to test ViewModel for React.

★ 2Forks 2JavaScriptGitHub ↗Compare

README

viewmodel-react-starter

Starter project to test ViewModel for React.

What's in it?

  • ViewModel
  • Example of testing VM components
  • Example of lazy loading a big component.
  • Simple src/index.js and src/index.css (local module css).
  • Webpack configuration for development (with hot reloading) and production (with minification).
  • CSS module loading, so you can include your css by import styles from './path/to.css';.
  • Both js and css hot loaded during development.
  • Webpack Dashboard Plugin on dev server.

To run

  • You'll need to have git and node installed in your system.
  • Fork and clone the project:
git clone https://github.com/alicoding/react-webpack-babel.git
  • Then install the dependencies:
npm install
  • Run development server:
npm start
npm run dev

Open the web browser to http://localhost:8888/

Test

npm test

To build the production package

npm run build

Nginx Config

Here is an example Nginx config:

server {
	# ... root and other options

	gzip on;
	gzip_http_version 1.1;
	gzip_types text/plain text/css text/xml application/javascript image/svg+xml;

	location / {
		try_files $uri $uri/ /index.html;
	}

	location ~ \.html?$ {
		expires 1d;
	}

	location ~ \.(svg|ttf|js|css|svgz|eot|otf|woff|jpg|jpeg|gif|png|ico)$ {
		access_log off;
		log_not_found off;
		expires max;
	}
}

Eslint

There is a .eslint.yaml config for eslint ready with React plugin. To use it, you need to install additional dependencies though:

npm install --save-dev eslint eslint-plugin-react

To do the actual linting, run:

npm run lint

Notes on importing css styles

  • styles having /src/ in their absolute path are considered part of the application and exported as local css modules.
  • other styles are considered global styles used by many components and are included in the css bundle directly.

Contribute

Please contribute to the project if you know how to make it better, including this README :)

Contributors

ManuelDeLeon

Issues