Sage assets.php --production vs development

I inadvertently built with Gulp --production on my development environment and so all the links to versioned assets broke until I rebuilt with a regular gulp.

I’m wondering what advantage there is to this line in assets.php (66)
if (WP_ENV !== ‘development’ && array_key_exists($file, $manifest->get())) {

Why not just
if (array_key_exists($file, $manifest->get())) {

It doesn’t matter so much which environment is running as it does which files exist in /dist/

Browser sync can’t auto reload revved files

Yes, understood. But there are only revved files in dist if you ‘gulp --production’ so browser sync won’t work, you don’t have the source maps and so on. But is that a reason to make the whole thing break? Why not allow the page to load properly but have some of the nice extras provided by ‘gulp watch’ not work?

I can see your point, however, gulp --production is signalling Production use… the only time it would really be run is when you are ready to upload files to the server, if that’s the workflow you’ll be using. All that’s needed is to run gulp again, so I wouldn’t call it broken, necessarily.

In my opinion, if the option is between your dev site looking unstyled after gulp --production, and Browsersync potentially breaking, I’ll take the easy fix of running gulp again.

1 Like

Hmm, good point. I’m all for making things super simple. Submit a PR!

Nope nope nope. Any time you want to test the exact functionality of what your staging, production will look like (or not look like due to bugs) you run --produciton. This is currently not possible due to checking the env. If we accept @colind’s PR it will make testing the sage theme easier as maintainers as well.

+1 to the PR, yay for simplicity!

PR: https://github.com/roots/sage/pull/1456

2 Likes

Thank you!

Post must be at least 20 characters