Skip to content

Commit 1f0bf9c

Browse files
authored
support custom run process (vuejs#331)
1 parent 845f549 commit 1f0bf9c

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

bin/vue-build

+4-2
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ if (!options.disableWebpackConfig) {
288288
if (typeof options.webpack === 'object') {
289289
webpackConfig = webpackMerge.smart(webpackConfig, options.webpack)
290290
} else if (typeof options.webpack === 'function') {
291-
webpackConfig = options.webpack(webpackConfig, options, webpack)
291+
webpackConfig = options.webpack(webpackConfig, options, webpack) || webpackConfig
292292
} else {
293293
var localWebpackConfigPath = typeof options.webpack === 'string'
294294
? cwd(options.webpack)
@@ -313,7 +313,9 @@ try {
313313

314314
checkEntryExists(options.entry)
315315

316-
if (options.watch) {
316+
if (typeof options.run === 'function') {
317+
options.run(webpackConfig, options)
318+
} else if (options.watch) {
317319
console.log('> Running in watch mode')
318320
rm(path.join(options.dist, '*'))
319321
compiler.watch({}, (err, stats) => handleBuild(err, stats, true))

docs/build.md

+23
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,29 @@ module.exports = {
219219
}
220220
```
221221

222+
#### run(webpackConfig, options)
223+
224+
Type: `function`
225+
226+
You can use a custom `run` function to perform your own build process instead of the default one. For example, run karma with the processed webpack config:
227+
228+
```js
229+
const Server = require('karma').Server
230+
231+
module.exports = {
232+
run(webpackConfig) {
233+
const server = new Server({
234+
webpack: webpackConfig,
235+
// other karma options...
236+
}, exitCode => {
237+
console.log('Karma has exited with ' + exitCode)
238+
process.exit(exitCode)
239+
})
240+
server.start()
241+
}
242+
}
243+
```
244+
222245
### webpack.config.js
223246

224247
All the webpack options are available here.

0 commit comments

Comments
 (0)