Distributing a next.js app via NPM #11606
Replies: 3 comments 9 replies
-
I've got the demo project working now! It looks like the webpack rule that next uses explicitly ignores all files within // from next.config.js
module.exports = {
webpack: (config) => {
const rule = config.module.rules[0];
const originalExcludeMethod = rule.exclude;
config.module.rules[0].exclude = (moduleName, ...otherArgs) => {
// we want to explicitly allow our plugin
if (moduleName.indexOf("node_modules/next-subproject-example") >= 0) {
return false;
}
// otherwise, use the original rule
return originalExcludeMethod(moduleName, ...otherArgs);
};
return config;
},
}; |
Beta Was this translation helpful? Give feedback.
-
Thanks for your solution. Great! I've similar situation: i have a core next js project( that is shipped as an npm package, like you said). But i have problem with weback, receiving this error: Could you provide some help? |
Beta Was this translation helpful? Give feedback.
-
I need some help on the same. I'm trying to build an app on next-js where i'm using SSR components. I want to build an npm package out of it which I can use in my old react project. |
Beta Was this translation helpful? Give feedback.
-
(related to and coppied from #11411)
Hello!
We are looking at distributing our next.js application via NPM, but are having trouble getting webpack to work properly when running next from /within/
node_modules
. We want to allow folks to runnext dev
andnext build
in our project so they can add plugins and modify behavior - meaning we can't runnext build
and ship that ourselves. Our users would install peerDependencies which would be bundled into the next application.The goal is to have something like this:
I've published
next-subproject-example
(github) to npm which is a very simple next.js application with one page and no custom config.package.json
, which aims to consumenext-subproject-example
npm install
npm run dev
Beta Was this translation helpful? Give feedback.
All reactions