Skip to content

Commit

Permalink
Merge pull request #1366 from roots/add-build-dir-constant
Browse files Browse the repository at this point in the history
Use a constant for the build directory path
  • Loading branch information
retlehs committed Mar 3, 2015
2 parents 0c25df7 + a57e07b commit 57df3ae
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
7 changes: 3 additions & 4 deletions lib/assets.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,13 @@ public function getPath($key = '', $default = null) {
}

function asset_path($filename) {
$dist_dir = '/dist/';
$dist_path = get_template_directory_uri() . $dist_dir;
$dist_path = get_template_directory_uri() . DIST_DIR;
$directory = dirname($filename) . '/';
$file = basename($filename);
static $manifest;

if (empty($manifest)) {
$manifest_path = get_template_directory() . $dist_dir . 'assets.json';
$manifest_path = get_template_directory() . DIST_DIR . 'assets.json';
$manifest = new JsonManifest($manifest_path);
}

Expand Down Expand Up @@ -131,7 +130,7 @@ function jquery_local_fallback($src, $handle = null) {
static $add_jquery_fallback = false;

if ($add_jquery_fallback) {
echo '<script>window.jQuery || document.write(\'<script src="' . get_template_directory_uri() . $dist_dir . 'scripts/jquery.js"><\/script>\')</script>' . "\n";
echo '<script>window.jQuery || document.write(\'<script src="' . get_template_directory_uri() . DIST_DIR . 'scripts/jquery.js"><\/script>\')</script>' . "\n";
$add_jquery_fallback = false;
}

Expand Down
5 changes: 5 additions & 0 deletions lib/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@
define('WP_ENV', 'production');
}

if (!defined('DIST_DIR')) {
// Path to the build directory for front-end assets
define('DIST_DIR', '/dist/');
}

/**
* Define which pages shouldn't have the sidebar
*/
Expand Down

0 comments on commit 57df3ae

Please sign in to comment.