Skip to content

Commit 720fdc2

Browse files
Merge pull request #7 from lenneTech/DEV-56
fix(DEV-56): Postbuild hook stopping process
2 parents 7c646fe + ee93a71 commit 720fdc2

File tree

2 files changed

+64
-50
lines changed

2 files changed

+64
-50
lines changed

nuxt-base-template/nuxt.config.ts

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,55 @@
11
// https://nuxt.com/docs/api/configuration/nuxt-config
2-
import tailwindcss from '@tailwindcss/vite'
2+
import tailwindcss from '@tailwindcss/vite';
33

44
export default defineNuxtConfig({
5-
ssr: true,
6-
7-
spaLoadingTemplate: false,
5+
app: {
6+
head: {
7+
title: 'Nuxt Base Starter',
8+
viewport: 'width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no',
9+
},
10+
},
811

9-
srcDir: './src',
12+
colorMode: {
13+
classSuffix: '',
14+
},
1015

11-
modules: [
12-
'@nuxt/test-utils/module',
13-
'@lenne.tech/nuxt-base',
14-
'@vueuse/nuxt',
15-
'@nuxtjs/google-fonts',
16-
'@nuxtjs/color-mode',
17-
'@nuxt/image',
18-
'@nuxtjs/robots',
19-
'@nuxtjs/sitemap',
20-
'@nuxtjs/plausible',
21-
],
16+
compatibilityDate: '2024-09-05',
2217

2318
css: ['~/assets/css/tailwind.css'],
2419

25-
vite: {
26-
plugins: [tailwindcss()],
27-
},
28-
29-
plausible: {
30-
apiHost: '',
20+
devServer: {
21+
port: 3001,
3122
},
3223

33-
compatibilityDate: '2024-09-05',
34-
3524
experimental: {
3625
asyncContext: true,
3726
renderJsonPayloads: false,
3827
typedPages: true,
3928
},
4029

41-
sitemap: {
42-
exclude: ['/app/**'],
43-
},
44-
4530
image: {
4631
ipx: {
4732
maxAge: 2592000,
4833
},
4934
provider: 'ipx',
5035
},
5136

37+
imports: {
38+
dirs: ['./states', './stores', './forms', './interfaces', './base', './plugins'],
39+
},
40+
41+
modules: [
42+
'@nuxt/test-utils/module',
43+
'@lenne.tech/nuxt-base',
44+
'@vueuse/nuxt',
45+
'@nuxtjs/google-fonts',
46+
'@nuxtjs/color-mode',
47+
'@nuxt/image',
48+
'@nuxtjs/robots',
49+
'@nuxtjs/sitemap',
50+
'@nuxtjs/plausible',
51+
],
52+
5253
nuxtBase: {
5354
generateTypes: process.env['GENERATE_TYPES'] === '1',
5455
gqlHost: process.env.API_URL + '/graphql',
@@ -57,11 +58,8 @@ export default defineNuxtConfig({
5758
storagePrefix: process.env.STORAGE_PREFIX,
5859
},
5960

60-
app: {
61-
head: {
62-
title: 'Nuxt Base Starter',
63-
viewport: 'width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no',
64-
},
61+
plausible: {
62+
apiHost: '',
6563
},
6664

6765
runtimeConfig: {
@@ -72,13 +70,15 @@ export default defineNuxtConfig({
7270
},
7371
},
7472

75-
devServer: {
76-
port: 3001,
73+
sitemap: {
74+
exclude: ['/app/**'],
7775
},
7876

79-
colorMode: {
80-
classSuffix: '',
81-
},
77+
spaLoadingTemplate: false,
78+
79+
srcDir: './src',
80+
81+
ssr: true,
8282

8383
// googleFonts: {
8484
// families: {
@@ -90,9 +90,9 @@ export default defineNuxtConfig({
9090
// stylePath: '~/assets/css/fonts.css',
9191
// },
9292

93-
imports: {
94-
dirs: ['./states', './stores', './forms', './interfaces', './base', './plugins'],
95-
},
96-
9793
telemetry: false,
94+
95+
vite: {
96+
plugins: [tailwindcss()],
97+
},
9898
});

nuxt-base-template/postbuild.js

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,26 @@
11
import { execSync } from 'child_process';
22
import * as path from 'path';
3+
34
const tslibPath = path.resolve('.output', 'server', 'node_modules', 'tslib');
4-
process.chdir(tslibPath);
5-
const command = 'npm pkg set "exports[.].import.node"="./tslib.es6.mjs"';
6-
try {
7-
execSync(command, { stdio: 'inherit' });
8-
console.debug('✅ Successfully ran postinstall script');
9-
} catch (error) {
10-
console.error('❌ Error executing postinstall script: ', error);
11-
process.exit(1);
5+
6+
async function runPostinstall() {
7+
const { default: config } = await import('./nuxt.config.ts');
8+
9+
if (!config.ssr) {
10+
console.debug('⚠️ SSR is disabled, skipping postinstall script.');
11+
process.exit(0);
12+
}
13+
14+
try {
15+
process.chdir(tslibPath);
16+
const command = 'npm pkg set \'exports[.].import.node\'=\'./tslib.es6.mjs\'';
17+
execSync(command, { stdio: 'inherit' });
18+
console.debug('✅ Successfully ran postinstall script');
19+
} catch (error) {
20+
console.error('❌ Error executing postinstall script:', error);
21+
process.exit(1);
22+
}
23+
1224
}
25+
26+
runPostinstall();

0 commit comments

Comments
 (0)