11const { default : styleguidist } = require ( 'vue-styleguidist' )
22const merge = require ( 'webpack-merge' )
33
4- module . exports = api => {
4+ module . exports = ( api , options ) => {
55 api . configureWebpack ( ( ) => ( {
66 // make sure that the docs blocks
77 // are ignored during normal serve & build
@@ -25,7 +25,7 @@ module.exports = api => {
2525 }
2626 } ,
2727 args => {
28- getStyleguidist ( args , api ) . binutils . build ( )
28+ getStyleguidist ( args , api , options ) . binutils . build ( )
2929 }
3030 )
3131
@@ -40,7 +40,7 @@ module.exports = api => {
4040 } ,
4141
4242 args => {
43- const server = getStyleguidist ( args , api ) . binutils . server ( args . open ) . app
43+ const server = getStyleguidist ( args , api , options ) . binutils . server ( args . open ) . app
4444
4545 // in order to avoid ghosted threads at the end of tests
4646 ; [ 'SIGINT' , 'SIGTERM' ] . forEach ( signal => {
@@ -68,13 +68,15 @@ module.exports = api => {
6868 )
6969}
7070
71- function getStyleguidist ( args , api ) {
71+ function getStyleguidist ( args , api , options ) {
7272 const conf = api . resolve ( args . config || './styleguide.config.js' )
73- const userWebpackConfig = conf && conf . length ? require ( conf ) . webpackConfig : { }
74-
73+ const sgConf = conf && conf . length ? require ( conf ) : { }
74+ const userWebpackConfig = sgConf . webpackConfig
75+ options . outputDir = sgConf . styleguideDir
76+ const cliWebpackConfig = getConfig ( api )
7577 return styleguidist (
7678 conf ,
77- config => ( config . webpackConfig = merge ( getConfig ( api ) , userWebpackConfig ) )
79+ config => ( config . webpackConfig = merge ( cliWebpackConfig , userWebpackConfig ) )
7880 )
7981}
8082
0 commit comments