getVersion();
function getUrl($fileName) {
global $version;
if (file_exists($fileName))
$fileVersion = strftime('%G%m%d%H%M%S', filemtime($fileName));
else
$fileVersion = $version;
return "$fileName?$fileVersion";
}
function js($fileName) {
return ''."\n";
}
function css($fileName) {
return ''."\n";
}
function getWebpackAssets() {
$wpConfig = json_decode(file_get_contents('webpack.config.json'));
$buildDir = $wpConfig->buildDir;
$serverPath = '';
if (_DEV_MODE) {
$devServerPort = $wpConfig->devServerPort;
$host = $_SERVER['SERVER_NAME'];
$serverPath = "http://$host:$devServerPort";
}
$wpAssets = json_decode(file_get_contents("$buildDir/webpack-assets.json"));
$jsFiles = [];
foreach ($wpAssets as $name => $asset)
if (!empty($name)
&& $name != '_empty_'
&& $name != 'main'
&& property_exists($asset, 'js'))
$jsFiles[] = $serverPath . $asset->js;
function addAssets($serverPath, &$jsFiles, $assets) {
foreach ($assets->js as $asset)
if (preg_match('/^chunk\./', basename($asset)) === 0)
$jsFiles[] = $serverPath.$asset;
}
if (isset($wpAssets->_empty_))
addAssets($serverPath, $jsFiles, $wpAssets->_empty_);
if (isset($wpAssets->{''}))
addAssets($serverPath, $jsFiles, $wpAssets->{''});
$jsFiles[] = $serverPath . $wpAssets->main->js;
return $jsFiles;
}