Skip to content

Commit

Permalink
Merge pull request #77 from ojvribeiro/fix-server-crashes-in-low-end
Browse files Browse the repository at this point in the history
fix(core): server crashes in low-end devices
  • Loading branch information
ojvribeiro authored Oct 21, 2022
2 parents 50943c9 + e947aac commit 7a85428
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 15 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vulmix",
"version": "0.5.5-beta.10",
"version": "0.5.5-beta.11",
"description": "Vue(3) meta-framework that uses Laravel Mix.",
"main": "./src/mix.js",
"scripts": {
Expand Down
11 changes: 11 additions & 0 deletions src/components/VulmixWelcome.vue
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
<template>
<Head>
<title>
Vue + Laravel Mix = Vulmix
</title>

<meta name="title" content="Vulmix starter application">
<meta name="description" content="Vulmix starter application description">

<link rel="icon" href="/assets/icons/favicon.png">
</Head>

<div class="p-6 space-y-6 bg-zinc-800 text-white h-full">
<h1 class="text-5xl">Home</h1>

Expand Down
46 changes: 32 additions & 14 deletions src/mix.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ const fs = require('fs')

const pkg = require('../package.json')

let isImgGenerated = false

require('laravel-mix-serve')
require('laravel-mix-simple-image-processing')
require('laravel-mix-replace-in-file')
Expand All @@ -30,20 +32,6 @@ class VulmixInit {
if (!fs.existsSync('./_dist/assets/img')) {
fs.mkdirSync('./_dist/assets/img', { recursive: true })
}

setTimeout(() => {
mix.imgs({
source: 'assets/img',
destination: '_dist/assets/img',
webp: true,
thumbnailsSizes: [1920, 1200, 900, 600, 300, 50],
smallerThumbnailsOnly: true,
thumbnailsOnly: false,
imageminWebpOptions: {
quality: 90,
},
})
}, 1000)
})

.setPublicPath('_dist')
Expand Down Expand Up @@ -115,6 +103,35 @@ class VulmixInit {
stats.compilation.assets[path] = asset
}
}

// Synchronous run
setTimeout(() => {
if (isImgGenerated === false) {
console.log('Generating optimized images...\n\n')

mix.imgs({
source: 'assets/img',
destination: '_dist/assets/img',
webp: true,
thumbnailsSizes: [1920, 1200, 900, 600, 300, 50],
smallerThumbnailsOnly: true,
thumbnailsOnly: false,
imageminWebpOptions: {
quality: 90,
},
})

isImgGenerated = true
}

console.log('\nServing on:')
console.log(
// Cyan
'\x1b[36m%s\x1b[0m',
'http://localhost:3000 (Live reload)\n' +
'http://localhost:8000 (No live reload)\n'
)
})
})

if (fs.existsSync('assets/icons/')) {
Expand Down Expand Up @@ -158,6 +175,7 @@ class VulmixInit {
)

.browserSync({
open: false,
proxy: 'localhost:8000',
files: [
'./app.vue',
Expand Down

0 comments on commit 7a85428

Please sign in to comment.