question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

versioning doesn't work when called inside of an if(production) conditionnal

See original GitHub issue

Using ^7.0

This works

mix.combine([
  'resources/assets/landing/css/devices/style.css',
  'resources/assets/landing/css/animate.css',
], 'public/dist/app.css').version();

mix.combine([
  'resources/assets/landing/js/main.js',
  'resources/assets/landing/vendor/push-menu/js/jasny-bootstrap.min.js',
], 'public/dist/app.js').version();

if (mix.inProduction) {
  mix.minify();
}

This doesn’t work

mix.combine([
  'resources/assets/landing/css/devices/style.css',
  'resources/assets/landing/css/animate.css',
], 'public/dist/app.css');

mix.combine([
  'resources/assets/landing/js/main.js',
  'resources/assets/landing/vendor/push-menu/js/jasny-bootstrap.min.js',
], 'public/dist/app.js');

if (mix.inProduction) {
  mix.minify();
  mix.version();
}

This last one never applies the versioning. I would like to only apply minification and versioning when I run npm run production, not when I run npm run dev

How can I achieve this?

In the first case, it does versioning whether I run dev or production

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

5reactions
forehalocommented, Feb 11, 2017

The mix used in webpack.mix.js is not an instance of Mix but a entry to specify webpack config. You should use

if (mix.config.inProduction) {
    mix.minify();
    mix.version();
}
3reactions
jsonUKcommented, Jan 22, 2018

Using the latest version 1.7.2, I believe this has changed again. I had to use the following to apply versioning to production.

if (mix.config.production) {
  mix.version();
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

How can I conditionally import an ES6 module? - Stack Overflow
You can now call the import keyword as a function (i.e. import() ) to load a module at runtime. It returns a Promise...
Read more >
Everything you wanted to know about the if statement
In this article. Conditional execution; The if statement; Comparison operators; Collection operators; Logical operators; Bitwise operators ...
Read more >
The 10 Most Common JavaScript Issues Developers Face
If you need help figuring out why your JavaScript isn't working, consult this list of the 10 most common JavaScript issues from a...
Read more >
Using version control and deploying | Looker - Google Cloud
You can make your fix in the new branch, and then deploy that branch's changes to production — before resuming work in your...
Read more >
Handling common JavaScript problems - MDN Web Docs
If you want this to work correctly, you can define a function to add the handler separately, calling it on each iteration and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found