@invisionag/webpack-config-ivx
v4.4.2
Published
# Description This package provides a baseline configuration for webpack as it is being used within our organisation. It adds:
Downloads
66
Maintainers
Keywords
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
- Install
@invisionag/webpack-config-ivx
as a development dependency. No need to add webpack or any loaders. - (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.
- 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.
- Publish your prerelease with
yarn publish
, then enter a version number ending with-my-branch-name.<someIncrementingNumber>
, for example (if we are currently at1.1.5
and you introduce minor, nonbreaking changes)1.2.0-maintenance-july-0
. - check out (for example) csv-importer-ui
- 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 - 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,
},
};
};