-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c134b22
commit ef05421
Showing
7 changed files
with
49 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,7 @@ yarn-error.log* | |
|
||
# Nuxt generate | ||
dist | ||
cache-mock | ||
.nuxt_build | ||
|
||
# Bulma build | ||
.tmp | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,40 @@ | ||
const fs = require('fs-extra') | ||
const path = require('path') | ||
const Rsync = require('rsync') | ||
|
||
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, 'dist') | ||
|
||
var rsync = new Rsync() | ||
const rsync = new Rsync() | ||
.shell('ssh') | ||
.flags('azq') | ||
.source(BUILD_PATH) | ||
.destination(CACHE_PATH); | ||
.source(BUILD_PATH + '/') | ||
.destination(CACHE_PATH) | ||
|
||
function cacheFinalFiles() { | ||
fs.copy((BUILD_PATH, CACHE_PATH) | ||
.then(() => console.log('successssss')) | ||
.catch(err => console.error(err)) | ||
export async function cacheFinalFiles() { | ||
try { | ||
await fs.copy(BUILD_PATH, CACHE_PATH) | ||
} catch (e) { | ||
console.log(e) | ||
} | ||
} | ||
|
||
fs.ensureDir(CACHE_PATH) | ||
.then(() => { | ||
rsync.execute(function(error, code, cmd) { | ||
// we're done | ||
if(!error) { | ||
fs.copy(CACHE_PATH, BUILD_PATH) | ||
.then(() => cacheFinalFiles()) | ||
.catch(err => console.error(err)) | ||
export async function cacheAndCopy() { | ||
try { | ||
await fs.ensureDir(CACHE_PATH) | ||
rsync.execute(async function(error, code, cmd) { | ||
if (!error) { | ||
await fs.copy(CACHE_PATH, BUILD_PATH) | ||
cacheFinalFiles() | ||
} | ||
}) | ||
}) | ||
} catch (err) { | ||
// handle error | ||
console.log(err) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,13 +3,13 @@ | |
"version": "1.0.0", | ||
"description": "Nuxt.js project", | ||
"author": "Hanbyul Jo <[email protected]>", | ||
"private": true, | ||
"scripts": { | ||
"initial-build": "INITIAL_BUILD=true nuxt generate", | ||
"incremental-build": "INITIAL_BUILD=false nuxt generate --no-build; node cache-me;", | ||
"incremental-build": "INITIAL_BUILD=false nuxt generate --no-build;", | ||
"dev": "DEPLOY_ENV=DEV nuxt", | ||
"build": "nuxt build", | ||
"start": "nuxt start", | ||
"clean-all": "rm -rf .nuxt; rm -rf dist;rm -rf .nuxt_build;", | ||
"generate": "nuxt generate", | ||
"generate-netlify": "DEPLOY_ENV=PRODUCTION nuxt generate", | ||
"lint": "eslint --ext .js,.vue --ignore-path .gitignore .", | ||
|
@@ -24,7 +24,6 @@ | |
"devDependencies": { | ||
"babel-eslint": "^10.0.1", | ||
"babel-plugin-dynamic-import-node": "^2.2.0", | ||
"cache-me-outside": "0.0.10", | ||
"eslint": "^5.9.0", | ||
"eslint-config-prettier": "^3.3.0", | ||
"eslint-friendly-formatter": "^3.0.0", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters