Skip to content

Commit

Permalink
Fix versioning running in production incorrectly
Browse files Browse the repository at this point in the history
This also returns versioning to dev mode.
  • Loading branch information
JeffreyWay committed Jan 24, 2017
1 parent 88f567a commit 9d14d7b
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/Mix.js
Expand Up @@ -17,6 +17,7 @@ class Mix {
this.sourcemaps = false;
this.notifications = true;
this.cssPreprocessor = false;
this.versioning = false;
this.inProduction = process.env.NODE_ENV === 'production';
this.publicPath = './';
}
Expand All @@ -37,7 +38,10 @@ class Mix {
require(this.Paths.mix());

this.manifest = new Manifest(this.publicPath + '/mix-manifest.json');
this.versioning = new Versioning(this.manifest);

if (this.versioning) {
this.versioning = new Versioning(this.manifest);
}

this.detectHotReloading();
}
Expand Down Expand Up @@ -97,7 +101,7 @@ class Mix {
*/
output() {
// We'll only apply a chunkhash in production, as it's a costly step.
let filename = (this.inProduction && this.versioning) ? '[name].[chunkhash].js' : '[name].js';
let filename = this.versioning ? '[name].[chunkhash].js' : '[name].js';

return {
path: this.hmr ? '/' : this.publicPath,
Expand All @@ -114,7 +118,7 @@ class Mix {
*/
cssOutput(segments) {
let regex = new RegExp('^(\.\/)?' + this.publicPath);
let pathVariant = (this.inProduction && this.versioning) ? 'hashedPath' : 'path';
let pathVariant = this.versioning ? 'hashedPath' : 'path';

return segments.output[pathVariant].replace(regex, '').replace(/\\/g, '/');
}
Expand Down

0 comments on commit 9d14d7b

Please sign in to comment.