next.config.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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. pageExtensions: ['page.tsx', 'page.ts', 'page.jsx', 'page.js'],
  16. /** @param config {import('next').NextConfig} */
  17. webpack(config, options) {
  18. // Avoid "Module not found: Can't resolve 'fs'"
  19. // See: https://stackoverflow.com/a/68511591
  20. if (!options.isServer) {
  21. config.resolve.fallback.fs = false;
  22. }
  23. // See: https://webpack.js.org/configuration/externals/
  24. // This provides a way of excluding dependencies from the output bundles
  25. config.externals.push('dtrace-provider');
  26. // configure additional entries
  27. const orgEntry = config.entry;
  28. config.entry = () => {
  29. return orgEntry().then((entry) => {
  30. return { ...entry, ...additionalWebpackEntries };
  31. });
  32. };
  33. // configure plugins
  34. const WebpackAssetsManifest = require('webpack-assets-manifest');
  35. config.plugins.push(
  36. new WebpackAssetsManifest({
  37. publicPath: true,
  38. output: 'custom-manifest.json',
  39. }),
  40. );
  41. return config;
  42. },
  43. };
  44. module.exports = withTM(nextConfig);