0

i have built a desktop application using nuxt 4 and electron js, everyting is working as perfect in dev mode loadig css , js everything but when it comes to package and prod the application installs and html content is loading but not getting any styles and js

Nuxt config:

import tailwindcss from "@tailwindcss/vite";

// https://nuxt.com/docs/api/configuration/nuxt-config
export default defineNuxtConfig({
  compatibilityDate: '2025-07-15',
  devtools: { enabled: true },
  css: ['~/assets/css/main.css'],
  ssr:false,
  app:{
    baseURL:'./',
    buildAssetsDir:'_nuxt/'
  },
  vite: {
    plugins: [
      tailwindcss(),
    ],
  },
})

Main:

let mainWindow: BrowserWindow | null = null

function createWindow() {
    mainWindow = new BrowserWindow({
        width: 400,
        height: 600,
        autoHideMenuBar: true,
        title: 'test application',
        titleBarStyle: 'hiddenInset',
        closable: true,
        webPreferences: {
            contextIsolation: true,
            nodeIntegration: false,
        }

    })

    if (!app.isPackaged) {
        mainWindow.loadURL('http://localhost:3000/')

    } else {
        const indexPath = path.join(
          __dirname,'../.output/public/index.html'
        )
        mainWindow.loadFile(indexPath)
    }
}

Package.json

{
  "name": "testapp",
  "private": true,
  "main": "out/main.js",
  "author": "test",
  "version": "1.0.0",
  "description": "An test application with electron js and nuxt",
  "scripts": {
    "build": "npm run compile && npm run generate",
    "dev": "concurrently \"nuxt dev\" \"npm run compile && electron out/main.js\"",
    "generate": "nuxt generate",
    "preview": "nuxt preview",
    "postinstall": "nuxt prepare",
    "compile": "tsc -p tsconfig.main.json",
    "build:win": "npm run build && electron-builder --win"
  },
  "dependencies": {
    "@tailwindcss/vite": "^4.1.14",
    "nuxt": "^4.1.3",
    "tailwindcss": "^4.1.14",
    "vue": "^3.5.22",
    "vue-router": "^4.5.1"
  },
  "devDependencies": {
    "concurrently": "^9.2.1",
    "electron": "^38.3.0",
    "electron-builder": "^26.0.12"
  },
  "build": {
    "appId": "test.app",
    "productName": "TestApp",
    "files": [
      "out/**/*",
      ".output/**/*"
    ],
    "win": {
      "target": [
        "nsis"
      ]
    }
  }
}

I have been tried many things changed url and ssr , app changing

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.