@@ -25,21 +25,36 @@ prog.command('dev')
25
25
. option ( '--hot' , 'Use hot module replacement (requires webpack)' , true )
26
26
. option ( '--live' , 'Reload on changes if not using --hot' , true )
27
27
. option ( '--bundler' , 'Specify a bundler (rollup or webpack)' )
28
+ . option ( '--cwd' , 'Current working directory' , '.' )
29
+ . option ( '--src' , 'Source directory' , 'src' )
30
+ . option ( '--routes' , 'Routes directory' , 'src/routes' )
31
+ . option ( '--static' , 'Static files directory' , 'static' )
32
+ . option ( '--output' , 'Sapper output directory' , '__sapper__' )
33
+ . option ( '--build-dir' , 'Development build directory' , '__sapper__/dev' )
28
34
. action ( async ( opts : {
29
35
port : number ,
30
36
open : boolean ,
31
37
'dev-port' : number ,
32
38
live : boolean ,
33
39
hot : boolean ,
34
- bundler ?: 'rollup' | 'webpack'
40
+ bundler ?: 'rollup' | 'webpack' ,
41
+ cwd : string ,
42
+ src : string ,
43
+ routes : string ,
44
+ static : string ,
45
+ output : string ,
46
+ 'build-dir' : string
35
47
} ) => {
36
- const cwd = path . resolve ( process . env . SAPPER_BASE || '' ) ;
37
-
38
48
const { dev } = await import ( './api/dev' ) ;
39
49
40
50
try {
41
51
const watcher = dev ( {
42
- cwd,
52
+ cwd : opts . cwd ,
53
+ src : opts . src ,
54
+ routes : opts . routes ,
55
+ static : opts . static ,
56
+ output : opts . output ,
57
+ dest : opts [ 'build-dir' ] ,
43
58
port : opts . port ,
44
59
'dev-port' : opts [ 'dev-port' ] ,
45
60
live : opts . live ,
@@ -125,18 +140,24 @@ prog.command('build [dest]')
125
140
. option ( '-p, --port' , 'Default of process.env.PORT' , '3000' )
126
141
. option ( '--bundler' , 'Specify a bundler (rollup or webpack, blank for auto)' )
127
142
. option ( '--legacy' , 'Create separate legacy build' )
143
+ . option ( '--cwd' , 'Current working directory' , '.' )
144
+ . option ( '--src' , 'Source directory' , 'src' )
145
+ . option ( '--routes' , 'Routes directory' , 'src/routes' )
146
+ . option ( '--output' , 'Sapper output directory' , '__sapper__' )
128
147
. example ( `build custom-dir -p 4567` )
129
148
. action ( async ( dest = '__sapper__/build' , opts : {
130
149
port : string ,
131
150
legacy : boolean ,
132
- bundler ?: 'rollup' | 'webpack'
151
+ bundler ?: 'rollup' | 'webpack' ,
152
+ cwd : string ,
153
+ src : string ,
154
+ routes : string ,
155
+ output : string
133
156
} ) => {
134
157
console . log ( `> Building...` ) ;
135
158
136
- const cwd = path . resolve ( process . env . SAPPER_BASE || '' ) ;
137
-
138
159
try {
139
- await _build ( opts . bundler , opts . legacy , cwd , dest ) ;
160
+ await _build ( opts . bundler , opts . legacy , opts . cwd , opts . src , opts . routes , opts . output , dest ) ;
140
161
141
162
const launcher = path . resolve ( dest , 'index.js' ) ;
142
163
@@ -159,33 +180,42 @@ prog.command('build [dest]')
159
180
prog . command ( 'export [dest]' )
160
181
. describe ( 'Export your app as static files (if possible)' )
161
182
. option ( '--build' , '(Re)build app before exporting' , true )
162
- . option ( '--build-dir' , 'Specify a custom temporary build directory' , '__sapper__/build' )
163
183
. option ( '--basepath' , 'Specify a base path' )
164
184
. option ( '--timeout' , 'Milliseconds to wait for a page (--no-timeout to disable)' , 5000 )
165
185
. option ( '--legacy' , 'Create separate legacy build' )
166
186
. option ( '--bundler' , 'Specify a bundler (rollup or webpack, blank for auto)' )
187
+ . option ( '--cwd' , 'Current working directory' , '.' )
188
+ . option ( '--src' , 'Source directory' , 'src' )
189
+ . option ( '--routes' , 'Routes directory' , 'src/routes' )
190
+ . option ( '--static' , 'Static files directory' , 'static' )
191
+ . option ( '--output' , 'Sapper output directory' , '__sapper__' )
192
+ . option ( '--build-dir' , 'Intermediate build directory' , '__sapper__/build' )
167
193
. action ( async ( dest = '__sapper__/export' , opts : {
168
194
build : boolean ,
169
195
legacy : boolean ,
170
196
bundler ?: 'rollup' | 'webpack' ,
171
- 'build-dir' : string ,
172
197
basepath ?: string ,
173
- timeout : number | false
198
+ timeout : number | false ,
199
+ cwd : string ,
200
+ src : string ,
201
+ routes : string ,
202
+ static : string ,
203
+ output : string ,
204
+ 'build-dir' : string ,
174
205
} ) => {
175
- const cwd = path . resolve ( process . env . SAPPER_BASE || '' ) ;
176
-
177
206
try {
178
207
if ( opts . build ) {
179
208
console . log ( `> Building...` ) ;
180
- await _build ( opts . bundler , opts . legacy , cwd , opts [ 'build-dir' ] ) ;
209
+ await _build ( opts . bundler , opts . legacy , opts . cwd , opts . src , opts . routes , opts . output , opts [ 'build-dir' ] ) ;
181
210
console . error ( `\n> Built in ${ elapsed ( start ) } ` ) ;
182
211
}
183
212
184
213
const { export : _export } = await import ( './api/export' ) ;
185
214
const { default : pb } = await import ( 'pretty-bytes' ) ;
186
215
187
216
await _export ( {
188
- static : path . resolve ( cwd , process . env . SAPPER_STATIC || 'static' ) ,
217
+ cwd : opts . cwd ,
218
+ static : opts . static ,
189
219
build_dir : opts [ 'build-dir' ] ,
190
220
export_dir : dest ,
191
221
basepath : opts . basepath ,
@@ -221,6 +251,9 @@ async function _build(
221
251
bundler : 'rollup' | 'webpack' ,
222
252
legacy : boolean ,
223
253
cwd : string ,
254
+ src : string ,
255
+ routes : string ,
256
+ output : string ,
224
257
dest : string
225
258
) {
226
259
const { build } = await import ( './api/build' ) ;
@@ -229,9 +262,9 @@ async function _build(
229
262
bundler,
230
263
legacy,
231
264
cwd,
232
- src : path . resolve ( cwd , process . env . SAPPER_SRC || 'src' ) ,
233
- routes : path . resolve ( cwd , process . env . SAPPER_ROUTES || 'src/routes' ) ,
234
- dest : path . resolve ( cwd , dest ) ,
265
+ src,
266
+ routes,
267
+ dest,
235
268
236
269
oncompile : event => {
237
270
let banner = `built ${ event . type } ` ;
0 commit comments