Skip to content

Support custom run process #331

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 4, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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