Fix loading style when development

This commit is contained in:
Pig Fang 2019-09-20 18:50:08 +08:00
parent 2a2491ac93
commit 74452a70de
2 changed files with 9 additions and 0 deletions

View File

@ -6,6 +6,7 @@ use App\Models\User;
use App\Services\Webpack;
use Illuminate\View\View;
use Illuminate\Http\Request;
use Illuminate\Support\Str;
use App\Services\Translations\JavaScript;
use Illuminate\Contracts\Events\Dispatcher;
@ -53,6 +54,9 @@ class FootComposer
if ($this->request->is('admin*') && auth()->user()->permission >= User::SUPER_ADMIN) {
$scripts[] = $this->webpack->url('check-updates.js');
}
if (Str::startsWith(config('app.asset.env'), 'dev')) {
$scripts[] = $this->webpack->url('style.js');
}
$scripts[] = $this->webpack->url('index.js');
$view->with([

View File

@ -25,6 +25,7 @@ class FootComposerTest extends TestCase
$crawler = new Crawler($this->get('/user')->getContent());
$this->assertCount(0, $crawler->filter('#disallowed'));
config(['app.asset.env' => 'development']);
$this->mock(JavaScript::class, function ($mock) {
$mock->shouldReceive('generate')
->with('en')
@ -42,6 +43,10 @@ class FootComposerTest extends TestCase
->with('check-updates.js')
->once()
->andReturn('check-updates.js');
$mock->shouldReceive('url')
->with('style.js')
->atLeast(1)
->andReturn('style.js');
$mock->shouldReceive('url')
->with('index.js')
->twice()