1- import path from 'node:path'
2- import { fileURLToPath } from 'node:url'
3- import { build } from 'velite'
4-
5- const __filename = fileURLToPath ( import . meta. url )
6- const __dirname = path . dirname ( __filename )
7-
81/** @type {import('next').NextConfig } */
9- export default {
10- webpack : ( config ) => {
11- config . plugins . push ( new VeliteWebpackPlugin ( ) )
12- return config
13- } ,
2+ const nextConfig = {
143 experimental : {
154 outputFileTracingIncludes : {
165 '/*' : [ '../components/**/*' , '../packages/panda/src/theme/recipes/**/*' ] ,
@@ -19,19 +8,12 @@ export default {
198 transpilePackages : [ 'shiki' ] ,
209}
2110
22- class VeliteWebpackPlugin {
23- static started = false
24- constructor ( /** @type {import('velite').Options } */ options = { } ) {
25- this . options = options
26- }
27- apply ( /** @type {import('webpack').Compiler } */ compiler ) {
28- compiler . hooks . beforeCompile . tapPromise ( 'VeliteWebpackPlugin' , async ( ) => {
29- if ( VeliteWebpackPlugin . started ) return
30- VeliteWebpackPlugin . started = true
31- const dev = compiler . options . mode === 'development'
32- this . options . watch = this . options . watch ?? dev
33- this . options . clean = this . options . clean ?? ! dev
34- await build ( this . options )
35- } )
36- }
11+ const isDev = process . argv . indexOf ( 'dev' ) !== - 1
12+ const isBuild = process . argv . indexOf ( 'build' ) !== - 1
13+ if ( ! process . env . VELITE_STARTED && ( isDev || isBuild ) ) {
14+ process . env . VELITE_STARTED = '1'
15+ const { build } = await import ( 'velite' )
16+ await build ( { watch : isDev , clean : ! isDev } )
3717}
18+
19+ export default nextConfig
0 commit comments