Created
October 25, 2016 14:31
-
-
Save jiripudil/706ea34d2830be89f8c084fd87d90407 to your computer and use it in GitHub Desktop.
Nette ♥ webpack-dev-server
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="cs"> | |
<head> | |
<title>{block title}Foo{/block}</title> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<link href="{$bundlePath}/styles.css" rel="stylesheet"> | |
</head> | |
<body> | |
{include #content} | |
<script src="{$bundlePath}/bundle.js"></script> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Presenters; | |
use Nette\Application\UI\Presenter; | |
abstract class BasePresenter extends Presenter implements IWebpackAwarePresenter | |
{ | |
/** @var string */ | |
private $bundlePath; | |
public function setBundlePath(string $bundlePath) | |
{ | |
$this->bundlePath = $bundlePath; | |
} | |
protected function beforeRender() | |
{ | |
$this->template->bundlePath = $bundlePath; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
decorator: | |
App\Presenters\IWebpackAwarePresenter: | |
setup: | |
- setBundlePath(%webpack.bundlePath%) | |
# in local.neon so that I can easily set it to dist directory in production | |
parameters: | |
webpack: | |
bundlePath: http://localhost:3000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Presenters; | |
interface IWebpackAwarePresenter | |
{ | |
public function setBundlePath(string $bundlePath); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment