rareyesdev / react-template

[⛔️ DEPRECATED] Template for React projects
0 stars 0 forks source link
deprecated react webpack

react-template ⛔️ DEPRECATED

No Maintenance Intended

Build Status

Deprecation note

This project was an experiment to understand the complexities behind a custom Webpack setup.

Description

This project is meant to contain basic setup for react applications

The app has basic features just to test the tools in the project

Table of Contents

Bootstrap

Theming

https://bootstrap.build/app/v4.0/

React Bootstrap

https://reactstrap.github.io/

Server

In production this app uses an Express server configured to serve files using the static middleware.

Eslint

Airbnb Configuration Overrides

Stylelint

Standard Configuration Overrides

Some CSS conventions where implemented following this article.

Git

Git hooks are enabled for checking JS and CSS against linter rules. Also, it will run tests before pushing

Webpack

Webpack Dev Server

To make WDS visible to other devices in the network we need to specify devServer.host using computer's name/IP. One solution is to use 0.0.0.0 or require('os').hostname().toLowerCase() but the last one will not allow opening the page in localhost

Optimizations

Considerations:

Webpack Bundle Analysis

The Official Webpack Analyzer runs using stats.json from npm run webpack-create-stats

Some other tools can be used to analyze Webpack output. This article contains a good reference for this.

From that article these options were reviewed, they look interesting but not enough to add them to the project:

Contribution Guidelines

README.md

Use Markdown TOC Visual Studio Code extension

~~Use markdown-toc to update TOC. In the project root folder execute: markdown-toc README.md~~

Modules

autoprefixer

PostCSS plugin to parse CSS and add vendor prefixes to CSS rules using values from Can I Use

babel-core

JS transpiler for using modern ECMAScript code

babel-eslint

Needed for eslint to parse advanced babel constructions

babel-loader

Webpack loader for .js and .jsx files

babel-plugin-istanbul

Add instrumenting code to ES6 source code. This is later used by a reporting service such as karma or mocha (through nyc)

babel-preset-env,babel-preset-react,babel-preset-stage-0

Presets for the transpiler to recognize modern ECMAScript constructions

bootstrap

Bootstrap 4 UI Framework (full framework with SCSS for compiling locally)

classnames

For using CSS Modules inside components. See bind

compression

Node.js compression middleware. Used by Express for asset compression

connect-history-api-fallback

Middleware to proxy requests through a specified index page, useful for Single Page Applications that utilise the HTML5 History API

cross-env

For settings Node environment variables in a cross-platform manner

css-loader

Webpack loader for .css files

express

Server

fast-sass-loader

SASS loader for webpack

file-loader

Webpack loader for files (png|svg|jpg|gif)

html-webpack-exclude-assets-plugin

Enhances html-webpack-plugin functionality by adding the {excludeAssets: RegExp | [RegExp]} option to allow you to exclude assets. Issue

html-webpack-plugin

For creating index.html automatically from a template file and inject JS and CSS bundles

inline-manifest-webpack-plugin

Inlines Webpack's runtime with a script tag to save an http request. Cause webpack's runtime always change between every build, it's better to split the runtime code out for long-term caching

mini-css-extract-plugin

Allows to extract all CSS files to a CSS bundle instead of bundling it with the JS code

morgan

Logger middleware for Express

node-sass

Provides binding for Node.js to LibSass, the C version of the popular stylesheet preprocessor, Sass. Required by fast-sass-loader

postcss-loader

Webpack loader for files .css files. Used after css-loader to plugin postcss-cssnext parser

Allows to process CSS using several plugins. Used after the CSS is parsed by the fast-sass-loader to apply vendor prefixes using autoprefixer

prop-types

Runtime type checking for React props

react,react-dom

React development

react-loadable

HOC for easy Code Splitting using Webpack

react-router-dom

React client router

reactstrap

React Bootstrap 4 components

remove-source-webpack-plugin

A plugin for webpack to remove the source that is not needed. Issue

rotating-file-stream

Creates a stream.Writable to a file which is rotated. Rotation behaviour can be deeply customized

shx

Wrapper around ShellJS Unix commands, providing an easy solution for simple Unix-like, cross-platform commands in npm package scripts. Used for deleting files in a cross-platform manner

style-loader

Adds CSS to the DOM by injecting a <style> tag

url-loader

Loads files as base64 encoded URL. Has file-loader as fallback option

webpack

Module bundler

webpack-cli

For using webpack from CLI

webpack-merge

Merge webpack configuration with ease

Modules (for development)

chai

Assertion framework. See expect usage in example tests

duplicate-package-checker-webpack-plugin

Webpack plugin that warns when your bundle contains multiple versions of the same package

eslint eslint-config-airbnb eslint-plugin-import eslint-plugin-jsx-a11y eslint-plugin-react

Linter, Airbnb configuration to eslint and plugins used by the configuration

husky

Add pre-commit and pre-push hooks to check linter and tests

mocha

Test runner

nodemon

nyc

Istanbul's state of the art command line interface. Reports code coverage in several formats

stylelint

Linter for CSS

stylelint-config-standard

Standard set of rules for stylelint

stylelint-order

Set of rules to order CSS property declarations

webpack-bundle-analyzer

Display webpack bundle statistics

webpack-dev-server

For running the app in development with hot reloading

Modules (deprecated)

This section contains documentation for modules that were previously used

postcss-cssnext

Parser for CssNext syntax

Replaced in favor of SCSS because Bootstrap gives SCSS files that can be compiled in place. This allow us to use the theme SCSS variables everywhere in the app

postcss-import

Allows to @import './styles/some-file.css' inside other CSS files

Not needed anymore since SCSS is now doing all the CSS processing

resolve-url-loader

Webpack loader that resolves relative paths in url() statements based on the original source file. This is required so we can specify relative URLs inside SCSS files. See sass-loader problems with url(). resolve-url-loader requires Source Maps enabled in sass-loader to work, then, we also need to enable Source Maps for postcss-loader otherwise it will ignore the previous Source Map and a warning will be generated (postcss-loader source maps)