Skip to content

Commit 5567f50

Browse files
bebrawjonathanglasmeyer
authored andcommitted
feat(lib): Add support for watchOptions
Implemented as discussed at https://webpack.github.io/docs/cli.html#additional-configuration-options . Closes #60.
1 parent d216727 commit 5567f50

File tree

5 files changed

+42
-0
lines changed

5 files changed

+42
-0
lines changed

src/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import nodeSchema from './properties/node'
99
import pluginsSchema from './properties/plugins'
1010
import resolveSchema from './properties/resolve'
1111
import outputSchema from './properties/output'
12+
import watchOptionsSchema from './properties/watchOptions'
1213
import { absolutePath } from './types'
1314

1415
const schema = Joi.object({
@@ -34,6 +35,7 @@ const schema = Joi.object({
3435
resolveLoader: resolveSchema.concat(Joi.object({
3536
moduleTemplates: Joi.array().items(Joi.string()),
3637
})),
38+
watchOptions: watchOptionsSchema,
3739
stats: Joi.any(), // TODO
3840
target: Joi.any(), // TODO
3941

src/properties/watchOptions/index.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import Joi from 'joi'
2+
3+
export default Joi.object({
4+
aggregateTimeout: Joi.number(),
5+
poll: [Joi.bool(), Joi.number()],
6+
})
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import schema from './index'
2+
import { allValid } from '../../../test/utils'
3+
4+
const validModuleConfigs = [
5+
// #0
6+
{ aggregateTimeout: 300 },
7+
// #1
8+
{ poll: true },
9+
// #2
10+
{ poll: false },
11+
// #3
12+
{ poll: 1000 },
13+
]
14+
15+
describe('watchOptions', () => {
16+
allValid(validModuleConfigs, schema)
17+
})
18+

test/passing-configs/watch-options.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
module.exports = {
2+
3+
watchOptions: {
4+
aggregateTimeout: 300,
5+
poll: true
6+
}
7+
8+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
module.exports = {
2+
3+
watchOptions: {
4+
aggregateTimeout: 300,
5+
poll: 1000
6+
}
7+
8+
}

0 commit comments

Comments
 (0)