Skip to content

Commit a8fbc50

Browse files
author
annrie
committed
fix: add DEPLOY_ENV for gh-pages
1 parent 824a060 commit a8fbc50

File tree

2 files changed

+22
-17
lines changed

2 files changed

+22
-17
lines changed

nuxt.config.ts

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,14 @@ import getSiteMeta from "./utils/getSiteMeta";
2121
const baseUrl = process.env.BASE_URL || "http://localhost:3000";
2222
const baseDir = process.env.BASE_DIR || "/";
2323
const basePath = baseUrl + baseDir;
24+
const routerBase =
25+
process.env.DEPLOY_ENV === "GH_PAGES"
26+
? {
27+
router: {
28+
base: "/Nuxtation/",
29+
},
30+
}
31+
: {};
2432

2533
// meta
2634
const lang = "en";
@@ -69,14 +77,15 @@ export default defineNuxtConfig({
6977
shortName,
7078
lang,
7179
},
72-
router: {
73-
base: '/nuxtation/',
74-
middleware: "pages",
75-
prefetchLinks: false,
76-
// middleware: ['pages','visits','user-agent'],
77-
linkActiveClass: "is-active",
78-
linkExactActiveClass: "is-exact-active",
79-
},
80+
...routerBase,
81+
// router: {
82+
// base: '/nuxtation/',
83+
// middleware: "pages",
84+
// prefetchLinks: false,
85+
// // middleware: ['pages','visits','user-agent'],
86+
// linkActiveClass: "is-active",
87+
// linkExactActiveClass: "is-exact-active",
88+
// },
8089
publicRuntimeConfig: {
8190
baseUrl: process.env.BASE_URL || "http://localhost:3000",
8291
googleAnalytics: {
@@ -533,10 +542,7 @@ export default defineNuxtConfig({
533542
** Nuxt.js dev-modules
534543
*/
535544
stylelint: {
536-
files: [
537-
"./src/assets/**/*.{s?(a|c)ss}",
538-
"{components,layouts,pages}/**/*.vue",
539-
],
545+
files: ["./src/assets/**/*.{s?(a|c)ss}", "{components,layouts,pages}/**/*.vue"],
540546
fix: true,
541547
},
542548
/*
@@ -625,8 +631,7 @@ export default defineNuxtConfig({
625631
],
626632
optimizedImages: {
627633
optimizeImages: true,
628-
imagesName: ({ isDev }) =>
629-
isDev ? "[path][name][hash:optimized].[ext]" : "img/[name].[ext]",
634+
imagesName: ({ isDev }) => (isDev ? "[path][name][hash:optimized].[ext]" : "img/[name].[ext]"),
630635
},
631636
// fontawesome: {
632637
// icons: {
@@ -862,9 +867,7 @@ export default defineNuxtConfig({
862867
}
863868
}
864869
// vue-svg-inline-loader
865-
const vueRule = config.module.rules.find((rule) =>
866-
rule.test.test(".vue")
867-
);
870+
const vueRule = config.module.rules.find((rule) => rule.test.test(".vue"));
868871
vueRule.use = [
869872
{
870873
loader: vueRule.loader,

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
"dev": "nuxi dev -o",
99
"production": "nuxi build --modern=server && nuxt start",
1010
"build": "nuxi build",
11+
"build:hg-pages": "DEPLOY_ENV=GH_PAGES nuxi build",
12+
"generate:gh-pages": "DEPLOY_ENV=GH_PAGES nuxi generate"
1113
"start": "node .output/server/index.mjs",
1214
"generate": "nuxi generate",
1315
"generate:production": "cross-env BASE_URL=https://nuxtation.phantomoon.com BASE_DIR=/ nuxt generate --fail-on-error --modern",

0 commit comments

Comments
 (0)