@@ -27,13 +27,11 @@ module.exports = (api, options) => {
27
27
args [ key ] = defaults [ key ]
28
28
}
29
29
}
30
- if ( args . dest == null ) {
31
- args . dest = options . outputDir
32
- }
33
30
34
31
api . setMode ( args . mode )
35
32
36
33
const fs = require ( 'fs' )
34
+ const path = require ( 'path' )
37
35
const chalk = require ( 'chalk' )
38
36
const rimraf = require ( 'rimraf' )
39
37
const webpack = require ( 'webpack' )
@@ -58,23 +56,48 @@ module.exports = (api, options) => {
58
56
}
59
57
}
60
58
59
+ // respect inline build destination
60
+ if ( args . dest ) {
61
+ api . configureWebpack ( {
62
+ output : {
63
+ path : path . resolve (
64
+ api . service . context ,
65
+ args . dest
66
+ )
67
+ }
68
+ } )
69
+ }
70
+
71
+ // resolve raw webpack config
72
+ let webpackConfig
73
+ if ( args . target === 'lib' ) {
74
+ webpackConfig = require ( './resolveLibConfig' ) ( api , args , options )
75
+ } else if (
76
+ args . target === 'wc' ||
77
+ args . target === 'wc-async'
78
+ ) {
79
+ webpackConfig = require ( './resolveWcConfig' ) ( api , args , options )
80
+ } else {
81
+ webpackConfig = api . resolveWebpackConfig ( )
82
+ }
83
+
84
+ // get final output directory from resolve raw config
85
+ // because the user may have manually overwritten it too
86
+ const config = Array . isArray ( webpackConfig )
87
+ ? webpackConfig [ 0 ]
88
+ : webpackConfig
89
+ const targetDir = config . output . path
90
+ const targetDirShort = path . relative (
91
+ api . service . context ,
92
+ targetDir
93
+ )
94
+
61
95
return new Promise ( ( resolve , reject ) => {
62
- const targetDir = api . resolve ( args . dest )
63
96
rimraf ( targetDir , err => {
64
97
if ( err ) {
65
98
return reject ( err )
66
99
}
67
- let webpackConfig
68
- if ( args . target === 'lib' ) {
69
- webpackConfig = require ( './resolveLibConfig' ) ( api , args , options )
70
- } else if (
71
- args . target === 'wc' ||
72
- args . target === 'wc-async'
73
- ) {
74
- webpackConfig = require ( './resolveWcConfig' ) ( api , args , options )
75
- } else {
76
- webpackConfig = api . resolveWebpackConfig ( )
77
- }
100
+
78
101
webpack ( webpackConfig , ( err , stats ) => {
79
102
stopSpinner ( false )
80
103
if ( err ) {
@@ -86,9 +109,9 @@ module.exports = (api, options) => {
86
109
}
87
110
88
111
if ( ! args . silent ) {
89
- log ( formatStats ( stats , options . outputDir , api ) )
112
+ log ( formatStats ( stats , targetDirShort , api ) )
90
113
if ( args . target === 'app' ) {
91
- done ( `Build complete. The ${ chalk . cyan ( options . outputDir ) } directory is ready to be deployed.\n` )
114
+ done ( `Build complete. The ${ chalk . cyan ( targetDirShort ) } directory is ready to be deployed.\n` )
92
115
if (
93
116
options . baseUrl === '/' &&
94
117
// only log the tips if this is the first build
0 commit comments