Skip to content

Commit bcb978f

Browse files
committed
Automatically build assets when UF_MODE is set to production
Also display UF_MODE in debug command
1 parent 3d0629c commit bcb978f

2 files changed

Lines changed: 11 additions & 2 deletions

File tree

app/system/Bakery/Command/BuildAssets.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,13 @@ protected function execute(InputInterface $input, OutputInterface $output)
5353
$this->npmInstall();
5454
$this->assetsInstall();
5555

56+
// Get current env mode
57+
// N.B.: Need to touch the config service first to load dotenv values
58+
$config = $this->ci->config;
59+
$mode = getenv("UF_MODE") ?: '';
60+
5661
// Compile if requested
57-
if ($input->getOption('compile')) {
62+
if ($input->getOption('compile') || $mode == "production") {
5863
$this->buildAssets();
5964
}
6065

@@ -99,7 +104,7 @@ protected function assetsInstall()
99104
*/
100105
protected function buildAssets()
101106
{
102-
$this->io->section("Building assets");
107+
$this->io->section("Building assets for production");
103108

104109
$this->io->writeln("> <comment>npm run uf-bundle-build</comment>");
105110
passthru("npm run uf-bundle-build --prefix " . $this->buildPath);

app/system/Bakery/Command/Debug.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ protected function execute(InputInterface $input, OutputInterface $output)
4646
$this->io->writeln("OS Name : " . php_uname('s'));
4747
$this->io->writeln("Project Root : {$this->projectRoot}");
4848

49+
// Need to touch the config service first to load dotenv values
50+
$config = $this->ci->config;
51+
$this->io->writeln("Environment mode : " . getenv("UF_MODE"));
52+
4953
// Perform tasks
5054
$this->checkPhpVersion();
5155
$this->checkNodeVersion();

0 commit comments

Comments
 (0)