mirror of
https://github.com/ThatGuySam/doesitarm.git
synced 2026-05-18 06:44:46 -07:00
Try incremental builds
This commit is contained in:
parent
522a1651c3
commit
e18262f422
4 changed files with 177 additions and 7 deletions
48
move-cache-back.js
Normal file
48
move-cache-back.js
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
const fs = require('fs-extra')
|
||||
const path = require('path')
|
||||
const { exec } = require("child_process")
|
||||
|
||||
const isProduction = process.env.NODE_ENV === 'PRODUCTION'
|
||||
|
||||
const CACHE_PATH = isProduction
|
||||
? path.join('/', 'opt', 'build', 'cache', 'nuxt_build') // Netlify cache path
|
||||
: path.resolve(__dirname, '.nuxt_build')
|
||||
|
||||
const BUILD_PATH = path.resolve(__dirname, '.nuxt')
|
||||
|
||||
async function putNuxtClientBack() {
|
||||
const exists = await fs.pathExists(CACHE_PATH)
|
||||
if (exists) {
|
||||
console.log("cache found")
|
||||
await fs.copy(CACHE_PATH, BUILD_PATH)
|
||||
exec('nuxt generate --no-build', (error, stdout, stderr) => {
|
||||
if (error) {
|
||||
console.log(`error: ${error.message}`);
|
||||
return;
|
||||
}
|
||||
if (stderr) {
|
||||
console.log(`stderr: ${stderr}`);
|
||||
return;
|
||||
}
|
||||
console.log(`stdout: ${stdout}`);
|
||||
});
|
||||
} else {
|
||||
console.log("no cache")
|
||||
exec('npm run generate', (error, stdout, stderr) => {
|
||||
if (error) {
|
||||
console.log(`error: ${error.message}`);
|
||||
return;
|
||||
}
|
||||
if (stderr) {
|
||||
console.log(`stderr: ${stderr}`);
|
||||
return;
|
||||
}
|
||||
console.log(`stdout: ${stdout}`);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
;(async () => {
|
||||
await putNuxtClientBack()
|
||||
|
||||
})()
|
||||
Loading…
Add table
Add a link
Reference in a new issue