| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- import { I18NextHMRPlugin } from 'i18next-hmr/plugin';
- import { WebpackManifestPlugin } from 'webpack-manifest-plugin';
- import { i18n, localePath } from './src/next-i18next.config';
- import { listScopedPackages } from './src/utils/next.config.utils';
- // define transpiled packages for '@growi/*'
- const scopedPackages = listScopedPackages(['@growi']);
- const withTM = require('next-transpile-modules')(scopedPackages);
- // define additional entries
- const additionalWebpackEntries = {
- boot: './src/client/boot',
- };
- /** @type {import('next').NextConfig} */
- const nextConfig = {
- reactStrictMode: true,
- typescript: {
- tsconfigPath: 'tsconfig.build.client.json',
- },
- pageExtensions: ['page.tsx', 'page.ts', 'page.jsx', 'page.js'],
- i18n,
- /** @param config {import('next').NextConfig} */
- webpack(config, options) {
- // Avoid "Module not found: Can't resolve 'fs'"
- // See: https://stackoverflow.com/a/68511591
- if (!options.isServer) {
- config.resolve.fallback.fs = false;
- }
- // See: https://webpack.js.org/configuration/externals/
- // This provides a way of excluding dependencies from the output bundles
- config.externals.push('dtrace-provider');
- // configure additional entries
- const orgEntry = config.entry;
- config.entry = () => {
- return orgEntry().then((entry) => {
- return { ...entry, ...additionalWebpackEntries };
- });
- };
- config.plugins.push(
- new WebpackManifestPlugin({
- fileName: 'custom-manifest.json',
- }),
- );
- // setup i18next-hmr
- if (!options.isServer && options.dev) {
- config.plugins.push(new I18NextHMRPlugin({ localesDir: localePath }));
- }
- return config;
- },
- };
- module.exports = withTM(nextConfig);
|