From fbfd61606989b5d8aaf182cd3595f616de795644 Mon Sep 17 00:00:00 2001 From: Huy Nguyen Date: Thu, 15 Dec 2016 11:59:50 -0500 Subject: [PATCH] feat: Allow performance.hints in webpack config (#150) * feat: Allow performance.hints in webpack config Webpack 2.1.0-beta.28 adds `performance.hints` (which take boolean values) as a way to enable/disable performance warnings. (The first performance warning is about bundle size.) * fix: Fix name of an import The test file for the `performance` property should import the test utils module using `utils` in lowercase but instead imported `Utils` in uppercase. This worked fine on my machine because my filesystem is case-insensitive but fails in Travis because its filesystem is case-sensitive. --- src/index.js | 2 ++ src/properties/performance/index.js | 5 +++++ src/properties/performance/index.test.js | 11 +++++++++++ 3 files changed, 18 insertions(+) create mode 100644 src/properties/performance/index.js create mode 100644 src/properties/performance/index.test.js diff --git a/src/index.js b/src/index.js index 60a64d6..933941b 100644 --- a/src/index.js +++ b/src/index.js @@ -11,6 +11,7 @@ import resolveSchemaFn from './properties/resolve' import outputSchema from './properties/output' import watchOptionsSchema from './properties/watchOptions' import devServerSchema from './properties/devServer' +import performanceSchema from './properties/performance' import { looksLikeAbsolutePath } from './types' import _merge from 'lodash/merge' import sh from 'shelljs' @@ -55,6 +56,7 @@ function makeSchema(schemaOptions, schemaExtension) { })), watch: Joi.boolean(), watchOptions: watchOptionsSchema, + performance: performanceSchema, stats: Joi.any(), // TODO target: Joi.any(), // TODO diff --git a/src/properties/performance/index.js b/src/properties/performance/index.js new file mode 100644 index 0000000..4836bd7 --- /dev/null +++ b/src/properties/performance/index.js @@ -0,0 +1,5 @@ +import Joi from 'joi' + +export default Joi.object({ + hints: Joi.boolean(), +}) diff --git a/src/properties/performance/index.test.js b/src/properties/performance/index.test.js new file mode 100644 index 0000000..d24bca5 --- /dev/null +++ b/src/properties/performance/index.test.js @@ -0,0 +1,11 @@ +import schema from './index' +import { allValid } from '../../../test/utils' + +const validPerformanceConfigs = [ + { input: { hints: true } }, + { input: { hints: false } }, +] + +describe('performance', () => { + allValid(validPerformanceConfigs, schema) +})