next.config.js 1.5 KB

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