mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2026-07-15 22:01:37 +00:00
Fix: build nuxt to commonjs target
This commit is contained in:
parent
228b5203a8
commit
03ed99d316
11 changed files with 14359 additions and 567 deletions
17
client/esbuild.js
Normal file
17
client/esbuild.js
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
const { build } = require('esbuild')
|
||||
|
||||
build({
|
||||
entryPoints: ['.output/server/index.mjs'],
|
||||
outfile: '.output/server/index.js',
|
||||
bundle: true,
|
||||
platform: 'node',
|
||||
format: 'cjs',
|
||||
ignoreAnnotations: true,
|
||||
sourcemap: true,
|
||||
inject: ['./esm-shims.js']
|
||||
}).then(() => {
|
||||
console.info('✔ Server compiled to commonjs target at .output/server/index.js')
|
||||
}).catch(() => {
|
||||
console.error('✘ Server failed to compile')
|
||||
process.exit(1)
|
||||
})
|
||||
7
client/esm-shims.js
Normal file
7
client/esm-shims.js
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
const path = require('path')
|
||||
const url = require('url');
|
||||
|
||||
const serverPath = path.resolve(__dirname, 'test.js')
|
||||
const serverUrl = url.pathToFileURL(serverPath).href
|
||||
|
||||
export { serverUrl as 'import.meta.url' }
|
||||
|
|
@ -14,4 +14,4 @@ const handler = listener
|
|||
);
|
||||
}
|
||||
|
||||
export { useRuntimeConfig, getRouteRules, handler, listener, useNitroApp };
|
||||
export { useRuntimeConfig, getRouteRules, handler, listener, useNitroApp }
|
||||
|
|
|
|||
|
|
@ -3,5 +3,5 @@ import { fileURLToPath } from 'node:url'
|
|||
|
||||
export default defineNitroPreset({
|
||||
extends: 'node-server',
|
||||
entry: fileURLToPath(new URL('./nitro.entry.js', import.meta.url))
|
||||
})
|
||||
entry: fileURLToPath(new URL('./nitro.entry.js', import.meta.url)),
|
||||
})
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
const { defineNuxtConfig } = require('@nuxt/bridge')
|
||||
import { fromNodeMiddleware } from 'h3';
|
||||
const pkg = require('./package.json')
|
||||
|
||||
module.exports = defineNuxtConfig({
|
||||
|
|
|
|||
14808
client/package-lock.json
generated
14808
client/package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
|
@ -2,11 +2,11 @@
|
|||
"name": "audiobookshelf-client",
|
||||
"version": "2.2.19",
|
||||
"description": "Self-hosted audiobook and podcast client",
|
||||
"main": "index.js",
|
||||
"main": ".output/server/index.js",
|
||||
"scripts": {
|
||||
"dev": "nuxi dev",
|
||||
"dev2": "nuxi dev --hostname localhost --port 1337",
|
||||
"build": "nuxi build",
|
||||
"build": "nuxi build && node esbuild.js",
|
||||
"start": "nuxi preview",
|
||||
"generate": "nuxi generate"
|
||||
},
|
||||
|
|
@ -33,6 +33,7 @@
|
|||
"devDependencies": {
|
||||
"@nuxtjs/tailwindcss": "^6.6.7",
|
||||
"autoprefixer": "^10.4.7",
|
||||
"esbuild": "^0.17.18",
|
||||
"minimatch": "^8.0.4",
|
||||
"postcss": "^8.3.6",
|
||||
"tailwindcss": "^3.1.4"
|
||||
|
|
|
|||
|
|
@ -1,29 +1,27 @@
|
|||
module.exports = {
|
||||
purge: {
|
||||
content: [
|
||||
'components/**/*.vue',
|
||||
'layouts/**/*.vue',
|
||||
'pages/**/*.vue',
|
||||
'templates/**/*.vue',
|
||||
'plugins/**/*.js',
|
||||
'nuxt.config.js'
|
||||
],
|
||||
safelist: [
|
||||
'bg-success',
|
||||
'bg-red-600',
|
||||
'bg-yellow-400',
|
||||
'text-green-500',
|
||||
'py-1.5',
|
||||
'bg-info',
|
||||
'px-1.5',
|
||||
'min-w-5',
|
||||
'w-3.5',
|
||||
'h-3.5',
|
||||
'border-warning',
|
||||
'mb-px',
|
||||
'text-1.5xl'
|
||||
],
|
||||
},
|
||||
content: [
|
||||
'components/**/*.vue',
|
||||
'layouts/**/*.vue',
|
||||
'pages/**/*.vue',
|
||||
'templates/**/*.vue',
|
||||
'plugins/**/*.js',
|
||||
'nuxt.config.js'
|
||||
],
|
||||
safelist: [
|
||||
'bg-success',
|
||||
'bg-red-600',
|
||||
'bg-yellow-400',
|
||||
'text-green-500',
|
||||
'py-1.5',
|
||||
'bg-info',
|
||||
'px-1.5',
|
||||
'min-w-5',
|
||||
'w-3.5',
|
||||
'h-3.5',
|
||||
'border-warning',
|
||||
'mb-px',
|
||||
'text-1.5xl'
|
||||
],
|
||||
theme: {
|
||||
extend: {
|
||||
height: {
|
||||
|
|
|
|||
11
package.json
11
package.json
|
|
@ -19,17 +19,16 @@
|
|||
"bin": "prod.js",
|
||||
"pkg": {
|
||||
"assets": [
|
||||
"client/.nuxt/**/*",
|
||||
"client/node_modules/**/*",
|
||||
"client/nuxt.config.js",
|
||||
"client/package.json",
|
||||
"client/modules/**/*",
|
||||
"client/static/**/*",
|
||||
"client/.output/server/index.js",
|
||||
"client/.output/public/**/*",
|
||||
"client/nuxt.config.js",
|
||||
"server/Db.js"
|
||||
],
|
||||
"scripts": [
|
||||
"prod.js",
|
||||
"server/**/*.js"
|
||||
"server/**/*.js",
|
||||
"client/.output/server/index.js"
|
||||
]
|
||||
},
|
||||
"author": "advplyr",
|
||||
|
|
|
|||
|
|
@ -331,7 +331,6 @@ class Server {
|
|||
|
||||
async stop() {
|
||||
this.watcher.close()
|
||||
this.clientRouter.stop()
|
||||
Logger.info('Watcher Closed')
|
||||
|
||||
return new Promise((resolve) => {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,4 @@
|
|||
const express = require('express')
|
||||
const mime = require('mime-types')
|
||||
const Path = require('path')
|
||||
const Logger = require('../Logger')
|
||||
|
||||
class ClientRouter {
|
||||
|
|
@ -8,31 +6,15 @@ class ClientRouter {
|
|||
this.appRoot = appRoot
|
||||
this.routerBasePath = routerBasePath
|
||||
|
||||
this.client = null
|
||||
this.router = express()
|
||||
this.router.disable('x-powered-by')
|
||||
}
|
||||
|
||||
async init () {
|
||||
const clientDir = Path.join(this.appRoot, '/client')
|
||||
const { handler } = await import(Path.join(clientDir, '.output/server/index.mjs'))
|
||||
this.client = handler
|
||||
}
|
||||
|
||||
async start () {
|
||||
Logger.info('[Client] Starting')
|
||||
await this.init()
|
||||
|
||||
this.router.use('/', this.client)
|
||||
}
|
||||
|
||||
async stop () {
|
||||
if (this.client) {
|
||||
await this.client.close()
|
||||
Logger.info('[Client] Stopped')
|
||||
} else {
|
||||
Logger.error('Client not running')
|
||||
}
|
||||
const { handler } = require('../../client')
|
||||
this.router.use('/', handler)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue