Open j4tmr opened 2 months ago
Do you have any insights of how to solve it?
AS far as I know, next.js standalone mode has the ability to copy static files, do that, and provide your own options.uiBasePath
.
@felixmosh I tried several ways, including nextjs's webpack configuration, but none of them worked. Your solution should be the same as me copying node_modules/@bull-board/ui directly to standalone in ci/cd. It needs to be copied dynamically.
What is the problem of this solution? it works.
Describe the Bug
When using Next.js in standalone mode, the
@bull-board/ui
package is not included in the final build, even though it is listed as a dependency in thepackage.json
. The package itself contains important static files required for the UI, but these files are missing from the final standalone output.Root Cause
The reason for this issue is that the
@bull-board/ui
package does not get directlyimport
ed into the application code. Next.js's standalone mode uses a file-tracing mechanism that relies on analyzing direct imports and references in the code to determine which files and packages should be included in the final build output. Since@bull-board/ui
is not directlyimport
ed but rather contains static assets that are necessary for the UI, the file-tracing mechanism does not detect it as needed for inclusion in the build. Consequently, the package's contents are omitted from the final standalone output, leading to missing assets and broken functionality.Expected Behavior
The
@bull-board/ui
package, along with all its static files, should be included in thestandalone
output when it's listed as a dependency.Suggested Solution
It would be beneficial if Next.js's standalone build process could more effectively handle such packages that contain essential static files but are not directly imported. One approach could be to enhance the file-tracing mechanism to consider these types of dependencies or provide a configuration option to manually include them.