Webpack 5 Template Boilerplate

Maintained by WeAreAthlon. Source code availalbe on GitHub logo GitHub.
MaintenanceBuild StatusCurrent Webpack VersionSnyk.io package health badge
GitHub IssuesKnown VulnerabilitiesnpmGitHub License
Webpack 5 Template Boilerplate

Demo page illustrating building of SASS, PostCSS, JavaScript, Fonts, Background Images and Inline Images.

Table of Contents

Features

"browserslist": [
          "last 2 versions",
          "> 5%"
      ]
      

Requirements

Setup

Installation

  1. Choose and download the latest template release from List of Releases.
  2. Extract the release archive to a new directory, rename it to your project name and browse the directory.
  3. Install all dependencies using npm clean install command.
$ npm ci

More on the clean install npm command can be read here npm ci

You can still use npm install in cases the npm ci raises system error due to specific platform incompatibilities.

Define Package Metadata

Configuration

Environment Configuration

Additional webpack configuration

You can additionally configure webpack for specific environment:

Development

Assets Source

Build Assets

One time build assets for development

$ npm run build
      

Build assets and enable source files watcher

$ npm run watch
      

This command is suitable if you develop with external web server.

Note: File watching does not work with NFS (Windows) and virtual machines under VirtualBox. Extend the configuration in such cases by:

module.exports = {
        //...
        watchOptions: {
          poll: 1000 // Check for changes every second
        }
      };
      

Start a development server - reloading automatically after each file change.

$ npm run dev
      

Production

Assets Building

Optimize assets for production by:

$ npm run production
      

Get Built Assets

Run Code Style Linters

SASS

$ npm run lint:sass

JavaScript

$ npm run lint:js

Additional Tools

Run Assets Bundle Analyzer

$ npm run stats

This will open the visualisaion on the default configuraiton URL localhost:8888, you can change this URL or port following the package documentation.

Continuous Integration

This boilerplate template contains integration with GitHub Actions. The build system runs all linting scripts and deploys production optimized pages to GitHub pages upon push to the master branch. However, note that this deployment flow only works for Project Pages, as User and Organization pages only support the master branch flow.

For more information on how to set up alternative deployment processes, check out the GitHub Actions documentation on deployment. The service can deploy to dozens of cloud providers, including Heroku, AWS, and Firebase.

Video File Preview