mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2026-07-16 06:11:38 +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({
|
export default defineNitroPreset({
|
||||||
extends: 'node-server',
|
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')
|
const { defineNuxtConfig } = require('@nuxt/bridge')
|
||||||
import { fromNodeMiddleware } from 'h3';
|
|
||||||
const pkg = require('./package.json')
|
const pkg = require('./package.json')
|
||||||
|
|
||||||
module.exports = defineNuxtConfig({
|
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",
|
"name": "audiobookshelf-client",
|
||||||
"version": "2.2.19",
|
"version": "2.2.19",
|
||||||
"description": "Self-hosted audiobook and podcast client",
|
"description": "Self-hosted audiobook and podcast client",
|
||||||
"main": "index.js",
|
"main": ".output/server/index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "nuxi dev",
|
"dev": "nuxi dev",
|
||||||
"dev2": "nuxi dev --hostname localhost --port 1337",
|
"dev2": "nuxi dev --hostname localhost --port 1337",
|
||||||
"build": "nuxi build",
|
"build": "nuxi build && node esbuild.js",
|
||||||
"start": "nuxi preview",
|
"start": "nuxi preview",
|
||||||
"generate": "nuxi generate"
|
"generate": "nuxi generate"
|
||||||
},
|
},
|
||||||
|
|
@ -33,6 +33,7 @@
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@nuxtjs/tailwindcss": "^6.6.7",
|
"@nuxtjs/tailwindcss": "^6.6.7",
|
||||||
"autoprefixer": "^10.4.7",
|
"autoprefixer": "^10.4.7",
|
||||||
|
"esbuild": "^0.17.18",
|
||||||
"minimatch": "^8.0.4",
|
"minimatch": "^8.0.4",
|
||||||
"postcss": "^8.3.6",
|
"postcss": "^8.3.6",
|
||||||
"tailwindcss": "^3.1.4"
|
"tailwindcss": "^3.1.4"
|
||||||
|
|
|
||||||
|
|
@ -1,29 +1,27 @@
|
||||||
module.exports = {
|
module.exports = {
|
||||||
purge: {
|
content: [
|
||||||
content: [
|
'components/**/*.vue',
|
||||||
'components/**/*.vue',
|
'layouts/**/*.vue',
|
||||||
'layouts/**/*.vue',
|
'pages/**/*.vue',
|
||||||
'pages/**/*.vue',
|
'templates/**/*.vue',
|
||||||
'templates/**/*.vue',
|
'plugins/**/*.js',
|
||||||
'plugins/**/*.js',
|
'nuxt.config.js'
|
||||||
'nuxt.config.js'
|
],
|
||||||
],
|
safelist: [
|
||||||
safelist: [
|
'bg-success',
|
||||||
'bg-success',
|
'bg-red-600',
|
||||||
'bg-red-600',
|
'bg-yellow-400',
|
||||||
'bg-yellow-400',
|
'text-green-500',
|
||||||
'text-green-500',
|
'py-1.5',
|
||||||
'py-1.5',
|
'bg-info',
|
||||||
'bg-info',
|
'px-1.5',
|
||||||
'px-1.5',
|
'min-w-5',
|
||||||
'min-w-5',
|
'w-3.5',
|
||||||
'w-3.5',
|
'h-3.5',
|
||||||
'h-3.5',
|
'border-warning',
|
||||||
'border-warning',
|
'mb-px',
|
||||||
'mb-px',
|
'text-1.5xl'
|
||||||
'text-1.5xl'
|
],
|
||||||
],
|
|
||||||
},
|
|
||||||
theme: {
|
theme: {
|
||||||
extend: {
|
extend: {
|
||||||
height: {
|
height: {
|
||||||
|
|
|
||||||
11
package.json
11
package.json
|
|
@ -19,17 +19,16 @@
|
||||||
"bin": "prod.js",
|
"bin": "prod.js",
|
||||||
"pkg": {
|
"pkg": {
|
||||||
"assets": [
|
"assets": [
|
||||||
"client/.nuxt/**/*",
|
|
||||||
"client/node_modules/**/*",
|
|
||||||
"client/nuxt.config.js",
|
|
||||||
"client/package.json",
|
"client/package.json",
|
||||||
"client/modules/**/*",
|
"client/.output/server/index.js",
|
||||||
"client/static/**/*",
|
"client/.output/public/**/*",
|
||||||
|
"client/nuxt.config.js",
|
||||||
"server/Db.js"
|
"server/Db.js"
|
||||||
],
|
],
|
||||||
"scripts": [
|
"scripts": [
|
||||||
"prod.js",
|
"prod.js",
|
||||||
"server/**/*.js"
|
"server/**/*.js",
|
||||||
|
"client/.output/server/index.js"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"author": "advplyr",
|
"author": "advplyr",
|
||||||
|
|
|
||||||
|
|
@ -331,7 +331,6 @@ class Server {
|
||||||
|
|
||||||
async stop() {
|
async stop() {
|
||||||
this.watcher.close()
|
this.watcher.close()
|
||||||
this.clientRouter.stop()
|
|
||||||
Logger.info('Watcher Closed')
|
Logger.info('Watcher Closed')
|
||||||
|
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,4 @@
|
||||||
const express = require('express')
|
const express = require('express')
|
||||||
const mime = require('mime-types')
|
|
||||||
const Path = require('path')
|
|
||||||
const Logger = require('../Logger')
|
const Logger = require('../Logger')
|
||||||
|
|
||||||
class ClientRouter {
|
class ClientRouter {
|
||||||
|
|
@ -8,31 +6,15 @@ class ClientRouter {
|
||||||
this.appRoot = appRoot
|
this.appRoot = appRoot
|
||||||
this.routerBasePath = routerBasePath
|
this.routerBasePath = routerBasePath
|
||||||
|
|
||||||
this.client = null
|
|
||||||
this.router = express()
|
this.router = express()
|
||||||
this.router.disable('x-powered-by')
|
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 () {
|
async start () {
|
||||||
Logger.info('[Client] Starting')
|
Logger.info('[Client] Starting')
|
||||||
await this.init()
|
|
||||||
|
|
||||||
this.router.use('/', this.client)
|
const { handler } = require('../../client')
|
||||||
}
|
this.router.use('/', handler)
|
||||||
|
|
||||||
async stop () {
|
|
||||||
if (this.client) {
|
|
||||||
await this.client.close()
|
|
||||||
Logger.info('[Client] Stopped')
|
|
||||||
} else {
|
|
||||||
Logger.error('Client not running')
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue