@invisionag/webpack-config-ivx

# Description This package provides a baseline configuration for webpack as it is being used within our organisation. It adds:

Stats

StarsIssuesVersionUpdatedCreatedSize
@invisionag/webpack-config-ivx
4.4.23 months ago3 years agoMinified + gzip package size for @invisionag/webpack-config-ivx in KB

Readme

@invisionag/webpack-config-ivx

Description

This package provides a baseline configuration for webpack as it is being used within our organisation. It adds:

Entries

  • Default entrypoint of ./src/index.js
  • babel-polyfills and fetch-polyfill

Loaders

  • JS loader with babel compilation
  • CSS loader
  • SVG loader
  • Image loader
  • Markdown loader
  • Font loader

We do not ship sass loaders since we're aiming to replace it with styled-components, and node-sass is a very heavy dependency, even for dev setups.

Plugins

  • HtmlWebpackPlugin takes an html template from ./src/index.html and injects scripts there

Optimization

  • Runtime-chunking
  • Chunk-splitting

Output

  • Outputs the template.html with injected scripts into the public folder, along with all chunks

DevServer

  • For development mode, start an IE compatible webserver with hot reloading on port 9002

Installation

  1. Install @invisionag/webpack-config-ivx as a development dependency. No need to add webpack or any loaders.
  2. (Optional) If you want to use a dev-server to run localle, install webpack-dev-server as a development dependency. Configuration will be handled by this package

Maintenance

  • run yarn upgrade-interactive --latest to update dependencies
  • make sure the node image used in the Dockerfile is the latest
  • run yarn test to verify everything is still running
  • publish a new version with yarn publish (see Publishing section)

Publishing

  • Make sure you are logged into NPM with npm whoami
  • Verify you are part of the invisionag organization on npm. If you aren't, ask any current member to invite you
  • Run yarn publish and enter a new version number (based on semVer)

Testing

A good way to test your changes is to publish a prerelease, then check out a repo using this config and update it to use the prerelease. Then, run this repos test suite and if everything still works, it's a good sign.

  1. Push your changes and create a PR to communicate that there is currently work going on, and to make the changes you want to introduce with the prerelease accessible to others.
  2. Publish your prerelease with yarn publish, then enter a version number ending with -my-branch-name.<someIncrementingNumber>, for example (if we are currently at 1.1.5 and you introduce minor, nonbreaking changes) 1.2.0-maintenance-july-0.
  3. check out (for example) csv-importer-ui
  4. change the version number of the dependency to this repository in the package.json to match your prerelease. You don't have to change the lockfile
  5. run yarn && yarn test.

If everything still works, you're looking good! You can now publish a regular version by running yarn publish again and simply leave the trailing prerelease stuff (1.2.0).

Usage

In your webpack.config.js, you can import this config as base config. Make sure you pass the current enviroment as an argument, so the base config can determine whether it is running in development or production mode:

const webpackConfigIvx = require('@invisionag/webpack-config-ivx');

module.exports = (env = 'development') => {
  const baseConfig = webpackConfigIvx(env);
  // ...
};

You can then extend the baseConfig as desired. A simple (complete) example to replace the devServer port would look like this:

module.exports = (env = 'development') => {
  const baseConfig = require('@invisionag/webpack-config-ivx')(env);
  return {
    ...baseConfig,
    devServer: {
      ...baseConfig.devServer,
      port: 9002,
    },
  };
};

If you find any bugs or have a feature request, please open an issue on github!

The npm package download data comes from npm's download counts api and package details come from npms.io.