next.config.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. import { listScopedPackages } from './src/utils/next.config.utils';
  2. // define transpiled packages for '@growi/*'
  3. const scopedPackages = listScopedPackages(['@growi']);
  4. const withTM = require('next-transpile-modules')(scopedPackages);
  5. // define additional entries
  6. const additionalWebpackEntries = {
  7. boot: './src/client/boot',
  8. };
  9. /** @type {import('next').NextConfig} */
  10. const nextConfig = {
  11. reactStrictMode: true,
  12. typescript: {
  13. tsconfigPath: 'tsconfig.build.client.json',
  14. },
  15. /** @param config {import('next').NextConfig} */
  16. webpack(config, options) {
  17. // Avoid "Module not found: Can't resolve 'fs'"
  18. // See: https://stackoverflow.com/a/68511591
  19. if (!options.isServer) {
  20. config.resolve.fallback.fs = false;
  21. }
  22. // See: https://webpack.js.org/configuration/externals/
  23. // This provides a way of excluding dependencies from the output bundles
  24. config.externals.push('dtrace-provider');
  25. // configure additional entries
  26. const orgEntry = config.entry;
  27. config.entry = () => {
  28. return orgEntry().then((entry) => {
  29. return { ...entry, ...additionalWebpackEntries };
  30. });
  31. };
  32. // configure plugins
  33. const WebpackAssetsManifest = require('webpack-assets-manifest');
  34. config.plugins.push(
  35. new WebpackAssetsManifest({
  36. publicPath: true,
  37. output: 'custom-manifest.json',
  38. }),
  39. );
  40. return config;
  41. },
  42. };
  43. module.exports = withTM(nextConfig);