KrystianRysnik / x13-website

MIT License
0 stars 0 forks source link

Webpack 4 Boilerplate

Maintenance webpack-current node-current (scoped) Build Status GitHub Issues Known Vulnerabilities Dependency Status devDependency Status npm GitHub License

Front-end Webpack Boilerplate

Features

Requirements

Setup

Installation

  1. Choose and download the template 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.
$ 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

const serverConfiguration = {
  internal: {
    server: {
      baseDir: 'dist',
    },
    port: 3000,
  },
  external: {
    proxy: 'http://localhost:9000/path/to/project/',
  },
};

Development / Build Assets

Assets Source

Build Assets

$ npm run build

Enable Source Files Watcher

$ npm run watch

Define any other files that needs syncing in files:[] section under BrowserSyncPlugin in webpack.config.js

BrowserSync UI can be reached by default on this location: http://localhost:3001

Enable Source Files Watcher Using an Existing Webserver

$ npm run watch:externalServer

Configure the URL to your running external web server in the webpack.config.json project under:

const serverConfiguration = {
  // ...,
  external: {
    proxy: 'http://localhost:3000/path/to/project/',
  },
};

Define any other files that needs syncing in files:[] section under BrowserSyncPlugin in webpack.config.js

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

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

Bundle

Executes both install and watch tasks in a single command convenient for development:

$ npm run bundle

Bundle (using external server for preview)

Executes both install and watch:externalServer tasks in a single command convenient for development with existing webserver back-end powered application:

$ npm run bundle:externalServer

Production / Build Assets

$ npm run production

Processed Built Assets

Run Code Style Linters

$ npm run lint-sass
$ npm run lint-js

Continuous Integration

This boilerplate template contains integration with Travis CI. 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 Travis CI documentation on deployment. The service can deploy to dozens of cloud providers, including Heroku, AWS, and Firebase.