∂Max
∂Max
NNuxt
Created by ∂Max on 10/4/2024 in #❓・help
No hot reload for runtime/plugin when developing custom nuxt content transformer
Hello 👋 While developing a custom nuxt/content transformer, I found myself having an annoying problem... Hot reload doesn't work for my runtime/plugin file... I followed the documentation at https://content.nuxt.com/recipes/transformers and have the following module.ts:
import { defineNuxtModule, createResolver, addComponentsDir } from '@nuxt/kit'

export default defineNuxtModule({
meta: {
name: 'my-module',
configKey: 'myModule',
},
// Default configuration options of the Nuxt module
defaults: {},
setup(_options, _nuxt) {
const { resolve } = createResolver(import.meta.url)

_nuxt.options.nitro.externals = _nuxt.options.nitro.externals || {}
_nuxt.options.nitro.externals.inline = _nuxt.options.nitro.externals.inline || []
_nuxt.options.nitro.externals.inline.push(resolve('./module'))

_nuxt.hook('content:context', (contentContext) => {
contentContext.transformers.push(resolve('./runtime/plugin.ts'))
})
},
})
import { defineNuxtModule, createResolver, addComponentsDir } from '@nuxt/kit'

export default defineNuxtModule({
meta: {
name: 'my-module',
configKey: 'myModule',
},
// Default configuration options of the Nuxt module
defaults: {},
setup(_options, _nuxt) {
const { resolve } = createResolver(import.meta.url)

_nuxt.options.nitro.externals = _nuxt.options.nitro.externals || {}
_nuxt.options.nitro.externals.inline = _nuxt.options.nitro.externals.inline || []
_nuxt.options.nitro.externals.inline.push(resolve('./module'))

_nuxt.hook('content:context', (contentContext) => {
contentContext.transformers.push(resolve('./runtime/plugin.ts'))
})
},
})
Thanks in advance for your help!
1 replies
NNuxt
Created by ∂Max on 8/8/2024 in #❓・help
Overriding the default getCachedData method of useAsyncData
Hello 👋 I'd like to change the behavior of getCachedData globally in my app. What is the best way to achieve that please?
1 replies
NNuxt
Created by ∂Max on 8/6/2024 in #❓・help
Nitro compressPublicAssets not working in docker image
Hey 👋 I added the following nitro config to my nuxt app:
nitro: {
preset: 'bun',
compressPublicAssets: {
brotli: true,
},
},
nitro: {
preset: 'bun',
compressPublicAssets: {
brotli: true,
},
},
But using compressPublicAssets prevents the nuxt build from correctly finishing in our docker image. There's no error, but there's also no files in .output/ Here's our docker file:
# use the official Bun image
# see all versions at https://hub.docker.com/r/oven/bun/tags
FROM oven/bun:1 AS base
WORKDIR /usr/src/app

# install dependencies into temp directory
# this will cache them and speed up future builds
FROM base AS install
RUN mkdir -p /temp/dev
COPY package.json bun.lockb /temp/dev/
RUN cd /temp/dev && bun install --frozen-lockfile

# install with --production (exclude devDependencies)
RUN mkdir -p /temp/prod
COPY package.json bun.lockb /temp/prod/
RUN cd /temp/prod && bun install --frozen-lockfile --production

# copy node_modules from temp directory
# then copy all (non-ignored) project files into the image
FROM base AS prerelease
COPY --from=install /temp/dev/node_modules node_modules
COPY . .

# [optional] tests & build
ENV NODE_ENV=production
RUN bun test
RUN bun run build

# copy production dependencies and source code into final image
FROM base AS release
COPY --from=prerelease /usr/src/app/.output .

# run the app
USER bun
EXPOSE 3000/tcp
ENTRYPOINT [ "bun", "run", "./server/index.mjs" ]
# use the official Bun image
# see all versions at https://hub.docker.com/r/oven/bun/tags
FROM oven/bun:1 AS base
WORKDIR /usr/src/app

# install dependencies into temp directory
# this will cache them and speed up future builds
FROM base AS install
RUN mkdir -p /temp/dev
COPY package.json bun.lockb /temp/dev/
RUN cd /temp/dev && bun install --frozen-lockfile

# install with --production (exclude devDependencies)
RUN mkdir -p /temp/prod
COPY package.json bun.lockb /temp/prod/
RUN cd /temp/prod && bun install --frozen-lockfile --production

# copy node_modules from temp directory
# then copy all (non-ignored) project files into the image
FROM base AS prerelease
COPY --from=install /temp/dev/node_modules node_modules
COPY . .

# [optional] tests & build
ENV NODE_ENV=production
RUN bun test
RUN bun run build

# copy production dependencies and source code into final image
FROM base AS release
COPY --from=prerelease /usr/src/app/.output .

# run the app
USER bun
EXPOSE 3000/tcp
ENTRYPOINT [ "bun", "run", "./server/index.mjs" ]
4 replies
NNuxt
Created by ∂Max on 7/18/2024 in #❓・help
get module options
Hey, I couldn't find how to get access at the options defined for my module within a nuxt component
2 replies
NNuxt
Created by ∂Max on 7/6/2024 in #❓・help
Fallback content using 'useAsyncData'
Hey! I'm using nuxt content to load some markdown content. In my use case, if the document is not found, I need to retry using other params. I was wondering what was the best way to implement this since I don't want to block the rendering and still cache the loaded content.
1 replies
NNuxt
Created by ∂Max on 6/24/2024 in #❓・help
Support of the new URL(..., import.meta.url) syntax?
Hey guys, I wanted to know if nuxt.js supports the new URL(..., import.meta.url) syntax. If there's none at the moment, can you tell me how I can help add it? This is a big blocker for an education project at the moment (I cannot fully use monaco-editor-wrapper).
6 replies
NNuxt
Created by ∂Max on 6/11/2024 in #❓・help
Nuxt content: attach data to md file
No description
2 replies
NNuxt
Created by ∂Max on 3/7/2023 in #❓・help
error caught during app initialization H3Error: Page not found: /sw.js
I don't really know why, but the router is throwing the error caught during app initialization H3Error: Page not found: /sw.js error. I simply have a basic app setup with just an index.vue file.
5 replies