Validates your webpack config with Joi
Clone or download
Pull request Compare This branch is 64 commits behind js-dxtools:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


Validate your webpack configs with joi

travis build dependencies devDependencies version downloads MIT License PRs Welcome Commitizen friendly semantic-release

Writing webpack configs is brittle and error-prone. This package provides a joi object schema for webpack configs. This gets you a) static type safety, b) property spell checking and c) semantic validations such as "loader and loaders can not be used simultaneously" or "query can only be used with loader, not with loaders".

You're very welcome to give feedback & PR's.


Take this simple webpack config. It has a tiny, hard to spot error. Can you find it?

var config = {
  module: {
    loaders: [
      { test: /\.js$/, loaders: 'babel-loader', exclude: /node_modules/ }
  output: {
    library: 'Redux',
    libraryTarget: 'umd'
  plugins: [
    new webpack.optimize.OccurenceOrderPlugin(),
    new webpack.DefinePlugin({
      'process.env.NODE_ENV': JSON.stringify(env)

webpack-validator makes it easy:



In your webpack.config.js:

const validate = require('webpack-validator')

module.exports = validate({ /* ... your webpack config */ })

Now run webpack. Either everything is green and the build continues or joi will let you know what's wrong and the build won't continue.

Alternatively just run node webpack.config.js to only validate your config and not run webpack.


If you need to extend the schema, for example for custom top level properties or properties added by third party plugins like eslint-loader (which adds a toplevel eslint property), do it like this:

const validate = require('webpack-validator')
const schema = require('webpack-validator').schema

// joi is installed as dependency of this package and will be available in node_modules
// if you use npm 3. Otherwise install it explicitly.
const Joi = require('joi')

const yourSchema = schema.concat(Joi.object({
  // this would just allow the property and doesn't perform any additional validation
  eslint: Joi.any()

const config = { /* ... your webpack config */ }

// Override default config by supplying your config as second parameter.
module.exports = validate(config, yourSchema)