Skip to content

Instantly share code, notes, and snippets.

@jiripudil
Created October 25, 2016 14:31
Show Gist options
  • Save jiripudil/706ea34d2830be89f8c084fd87d90407 to your computer and use it in GitHub Desktop.
Save jiripudil/706ea34d2830be89f8c084fd87d90407 to your computer and use it in GitHub Desktop.
Nette ♥ webpack-dev-server
<!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>
<?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;
}
}
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
<?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