Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(core): server crashes in low-end devices #77

Merged
merged 10 commits into from
Oct 21, 2022
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