#How to include a package in a standalone build
1 messages · Page 1 of 1 (latest)
Hi @rotund crypt. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
To include a package in a standalone build that was not directly imported in the Next.js app, you can use the built-in functionality of Next.js to include additional files. This is done by modifying the next.config.js file.
Here is an example of how to do it:
module.exports = {
experimental: {
outputFileTracingIncludes: {
'/api/another': ['./necessary-folder/**/*'],
},
},
}
In this example, the outputFileTracingIncludes option is used to specify additional files or directories to be included in the build. The file path can be a glob to select multiple files.
If you are using a monorepo and you need to include files outside of the application's root directory, you can use the outputFileTracingRoot option:
const path = require('path');
module.exports = {
experimental: {
outputFileTracingRoot: path.join(__dirname, '../../'),
},
}
In this example, the outputFileTracingRoot option is set to the monorepo base two directories up from the application's root directory.
Please note that these options are experimental and may change in future versions of Next.js.