1.1.0 • Published 10 months ago

next-subproject-examples v1.1.0

Weekly downloads
-
License
ISC
Repository
-
Last release
10 months ago

next-subproject-example

This project aims to demonstrate how you can ship a next.js application as a node_module.

This sample project has been published to NPM as next-subproject-example.

  1. Make a new project with the following package.json, which aims to consume next-subproject-example
{
  "name": "my-project",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "dev": "cd node_modules/next-subproject-example && npm run dev",
    "build": "cd node_modules/next-subproject-example && npm run prepare"
  },
  "dependencies": {
    "next-subproject-example": "latest"
  },
  "license": "ISC",
  "devDependencies": {
    "@types/node": "^13.9.5",
    "@types/react": "^16.9.26"
  }
}
  1. npm install
  2. npm run dev
  3. npm run build

How does this work?

We patch next's webpack loader in config.next.js. By default, next.js excludes building all node_modules... but we want to! We metaprogram around the original webpack rule, and explicitly allow our node_module.

1.1.0

10 months ago