* @param {object} [options] See https://webpack.js.org/configuration/dev-server/ * @param {string|string[]} [entry] * @return {Function}
(options = {}, entry = [])
| 12 | * @return {Function} |
| 13 | */ |
| 14 | function devServer(options = {}, entry = []) { |
| 15 | if (options && (typeof options === 'string' || Array.isArray(options))) { |
| 16 | entry = options |
| 17 | options = {} |
| 18 | } |
| 19 | |
| 20 | if (!Array.isArray(entry)) { |
| 21 | entry = entry ? [entry] : [] |
| 22 | } |
| 23 | |
| 24 | const setter = context => prevConfig => { |
| 25 | context.devServer = context.devServer || { entry: [], options: {} } |
| 26 | context.devServer.entry = context.devServer.entry.concat(entry) |
| 27 | context.devServer.options = Object.assign({}, context.devServer.options, options) |
| 28 | |
| 29 | return prevConfig |
| 30 | } |
| 31 | |
| 32 | return Object.assign(setter, { post: postConfig }) |
| 33 | } |
| 34 | |
| 35 | function postConfig(context, util) { |
| 36 | const entryPointsToAdd = context.devServer.entry |
no outgoing calls
no test coverage detected
searching dependent graphs…