In my setup, we develop on our local machines, and then rsync our code into a stray box.
I got this working by running the webpack -wrsync daemon together too - webpack creates the files, and then rsync immediately picks up the changes and downloads them.
However, this will not work with direct / hot reload. So I was hoping to do this in order to swap these two lines in my HTML:
<script src="/assets/bundle-ba00eb4a9c20608dbf97.js" charset="utf-8"></script>
<link href="/assets/bundle-f6d909a555852937509481b27fc2ce5d.css" rel="stylesheet" type="text/css; charset=utf-8" />
With something like:
<script src="http://localhost:8080/bundle.js" charset="utf-8"></script>
And then a live / hot reboot will magically work.
I cannot run my entire application under a webpack-dev server, because nginx should still serve the rest of the PHP application, including some insecure resources.
Currently, these two HTML lines are generated by this function:
function($chunkName) {
static $stats;
if($stats === null) {
$stats = WxJson::loadFile(WX::$path.'/webpack.stats.json');
}
$paths = WXU::array_get($stats,['assetsByChunkName',$chunkName],false);
if($paths === false) {
throw new \Exception("webpack asset not found: $chunkName");
}
$html = [];
foreach((array)$paths as $p) {
$ext = WXU::GetFileExt($p);
switch($ext) {
case 'js':
$html[] = WXU::html_tag('script',['src'=>WXU::join_path($stats['publicPath'],$p),'charset'=>'utf-8'],'');
break;
case 'css':
$html[] = WXU::html_tag('link',['href'=>WXU::join_path($stats['publicPath'],$p),'rel'=>'stylesheet','type'=>'text/css; charset=utf-8'],null);
break;
}
}
return implode(PHP_EOL, $html);
}
, webpack-dev- webpack.stats.json "live", - .
, , , webpack-dev-server, , , , , PHP.
, , . , :
-? URL- , , webpack-dev-, , webpack-dev- - ?
PHP, , webpack-dev-?
webpack.config.js, .
'webpack-dev-server/client?http://localhost:5584/assets/',
'webpack/hot/only-dev-server',
new webpack.HotModuleReplacementPlugin() webpack.config.json ( webpack not webpack-dev-server), Chrome:
GET http:
[WDS] Disconnected!
. , , , URL- PHP CORS.