Based off of this blog post by Joesph Luck
The idea behind this is that each directory (base, siteuno, ...) can use code from other directories despite them being different projects.
Treat each directory as a seperate next.js project. Run commands such as yarn and yarn dev from inside those directories, not the root directory.
- Duplicate the "siteuno" directory
- Change name in
new_dir/package.jsonto@mono/new-dir - Add the directory to
./package.json - Start importing from other directories! (make sure you add each directory that you want to import to that directory's
package.json- seesiteuno/package.json)
The next.config.js in each directory will grab any modules with the scope @mono and build them. Then you can import files from a given directory, as in the example shown below:
import Header from '@mono/base/components/Header'NB: you can change the @mono to something else, such as @followmsrcodesontwitter by changing the name value in ./package.json and then changing it in every next.config.js file