Skip to content

Commit

Permalink
support custom run process (vuejs#331)
Browse files Browse the repository at this point in the history
  • Loading branch information
egoist authored Feb 4, 2017
1 parent 845f549 commit 1f0bf9c
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
6 changes: 4 additions & 2 deletions bin/vue-build
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ if (!options.disableWebpackConfig) {
if (typeof options.webpack === 'object') {
webpackConfig = webpackMerge.smart(webpackConfig, options.webpack)
} else if (typeof options.webpack === 'function') {
webpackConfig = options.webpack(webpackConfig, options, webpack)
webpackConfig = options.webpack(webpackConfig, options, webpack) || webpackConfig
} else {
var localWebpackConfigPath = typeof options.webpack === 'string'
? cwd(options.webpack)
Expand All @@ -313,7 +313,9 @@ try {

checkEntryExists(options.entry)

if (options.watch) {
if (typeof options.run === 'function') {
options.run(webpackConfig, options)
} else if (options.watch) {
console.log('> Running in watch mode')
rm(path.join(options.dist, '*'))
compiler.watch({}, (err, stats) => handleBuild(err, stats, true))
Expand Down
23 changes: 23 additions & 0 deletions docs/build.md
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,29 @@ module.exports = {
}
```

#### run(webpackConfig, options)

Type: `function`

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:

```js
const Server = require('karma').Server

module.exports = {
run(webpackConfig) {
const server = new Server({
webpack: webpackConfig,
// other karma options...
}, exitCode => {
console.log('Karma has exited with ' + exitCode)
process.exit(exitCode)
})
server.start()
}
}
```

### webpack.config.js

All the webpack options are available here.
Expand Down

0 comments on commit 1f0bf9c

Please sign in to comment.