File tree Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -27,6 +27,7 @@ const DEFAULT_OPTIONS = {
27
27
pathPrefix : "/" , // May be overridden by Eleventy, adds a virtual base directory to your project
28
28
watch : [ ] , // Globs to pass to separate dev server chokidar for watching
29
29
aliases : { } , // Aliasing feature
30
+ rebuildUrl : null , // POST URL to trigger rebuild
30
31
31
32
// Logger (fancier one is injected by Eleventy)
32
33
logger : {
@@ -79,6 +80,10 @@ class EleventyDevServer {
79
80
this . options . pathPrefix = this . cleanupPathPrefix ( this . options . pathPrefix ) ;
80
81
}
81
82
83
+ setEventBus ( _eventBus ) {
84
+ this . eventBus = _eventBus ;
85
+ }
86
+
82
87
get watcher ( ) {
83
88
if ( ! this . _watcher ) {
84
89
debug ( "Watching %O" , this . options . watch ) ;
@@ -415,6 +420,12 @@ class EleventyDevServer {
415
420
}
416
421
417
422
eleventyDevServerMiddleware ( req , res , next ) {
423
+ if ( this . options . rebuildUrl && req . url === this . options . rebuildUrl && req . method === 'POST' ) {
424
+ this . eventBus . emit ( 'eleventyDevServer.rebuild' ) ;
425
+ res . writeHead ( 200 ) ;
426
+ return res . end ( ) ;
427
+ }
428
+
418
429
if ( req . url === `/${ this . options . injectedScriptsFolder } /reload-client.js` ) {
419
430
if ( this . options . liveReload ) {
420
431
res . setHeader ( "Content-Type" , mime . getType ( "js" ) ) ;
You can’t perform that action at this time.
0 commit comments