zce / velite

Turns Markdown / MDX, YAML, JSON, or others into app's data layer with Zod schema.
http://velite.js.org
MIT License
476 stars 23 forks source link

content not rebuilding when modify/change files under the 'content' directory using next 14.1.3 #94

Closed miftahur-ridwan closed 7 months ago

miftahur-ridwan commented 7 months ago

Hello, im trying velite for the first time, its working and nice projects! But i have weird issue, i try to modify or change the files under the 'content' directory, but not rebuilding and not showing anything on the terminal.

image

Integration with Next 14.1.3. This is my velite config: here

Im on node v20.12.0 Try use node v.20.9.0, v18.19.0 and still same.

I try next.config same as velite documentation, but still same.

import { build } from 'velite'

/** @type {import('next').NextConfig} */
export default {
  // othor next config here...
  webpack: config => {
    config.plugins.push(new VeliteWebpackPlugin())
    return config
  }
}

class VeliteWebpackPlugin {
  static started = false
  constructor(/** @type {import('velite').Options} */ options = {}) {
    this.options = options
  }
  apply(/** @type {import('webpack').Compiler} */ compiler) {
    // executed three times in nextjs !!!
    // twice for the server (nodejs / edge runtime) and once for the client
    compiler.hooks.beforeCompile.tapPromise('VeliteWebpackPlugin', async () => {
      if (VeliteWebpackPlugin.started) return
      VeliteWebpackPlugin.started = true
      const dev = compiler.options.mode === 'development'
      this.options.watch = this.options.watch ?? dev
      this.options.clean = this.options.clean ?? !dev
      await build(this.options) // start velite
    })
  }
}
miftahur-ridwan commented 7 months ago

Finally solved after moved project to other directory. 🫨 I think the issue is permission on my mac os environment (folder get corrupted maybe) i have no idea. 🧐

Screenshot 2024-03-28 at 03 04 48

Reference: https://stackoverflow.com/a/28610124