Reputation: 83
I work with a huge monorepo. The production build for our next app takes about 20 minutes. I am trying bring this number down.
Issue: I was exploring module.noParse
callback exposed by webpack and noticed that during the build for server and client, not only the source files, but the mock json files, test utils and story files were being read. This happens twice(server & client). This was expected. There are some libs which export mocks and other files which are used by some other libraries.
In my opinion, resolving and reading files is one of costliest operations during a build step. I am trying to check if there is a way we can avoid reading these files during the build. Here is what I have tried so far:
"next": "12.3.4"
Add ignore-loader
to the webpack config - this does not work for me because the index file which was originally exporting the mock json files, test utils and story files errors out - Module not found: Can't resolve 'ignore-loader' in '/path/to/my/app'
webpackConfig.module.rules?.push({
test: /stories|tests|mocks/,
loader: "ignore-loader",
});
Tried adding config.module.rules[x].exclude = /stories|tests|mocks/;
- But this does not exclude the files I want to ignore
Am I on the right path here? I have spent a considerable amount of time trying to figure this out without any success.
Upvotes: 1
Views: 221