Skip to content

Commit

Permalink
Added auto host mode for webpack dev server.
Browse files Browse the repository at this point in the history
  • Loading branch information
colintucker committed Mar 22, 2018
1 parent b3b4595 commit b1ae544
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion _config/controller.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Only:

SilverStripe\CMS\Controllers\ContentController:
dev_server:
host: localhost
host: auto
port: 8080
https: auto
timeout: 10
Expand Down
12 changes: 12 additions & 0 deletions src/Extensions/ControllerExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,12 @@ public function getDevServerURL($path = null)

if (isset($config['host']) && isset($config['port'])) {

// Auto Host Mode:

if ($config['host'] === 'auto') {
$config['host'] = Director::host();
}

// Define Protocol:

$protocol = function ($config) {
Expand Down Expand Up @@ -461,6 +467,12 @@ protected function testDevServer()

if (isset($config['host']) && isset($config['port'])) {

// Auto Host Mode:

if ($config['host'] === 'auto') {
$config['host'] = Director::host();
}

// Define Timeout:

$timeout = isset($config['timeout']) ? $config['timeout'] : 10;
Expand Down

0 comments on commit b1ae544

Please sign in to comment.