-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnext.config.ts
More file actions
76 lines (66 loc) · 2.22 KB
/
Copy pathnext.config.ts
File metadata and controls
76 lines (66 loc) · 2.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import type { NextConfig } from "next";
import createNextIntlPlugin from 'next-intl/plugin';
const withNextIntl = createNextIntlPlugin('./src/i18n/request.ts');
const nextConfig: NextConfig = {
output: "export",
images: { unoptimized: true },
// Canonical URLs carry a trailing slash (e.g. /en/, /en/tools/merge-pdf/).
// The static export then emits `<route>/index.html` so hosters serve the
// slash version directly (200) instead of 307-redirecting to the
// no-slash variant, which Google refuses to index / pass equity to.
trailingSlash: true,
// Lint is run separately via `npm run lint` (ESLint flat config).
// The build's job is compile + type-check; don't fail it on the
// inherited PDFCraft lint debt (mostly no-explicit-any in WASM/PDF glue).
eslint: { ignoreDuringBuilds: true },
// Turbopack (dev) does NOT use the webpack() config below, so the Node-only
// `require("canvas")` in pdfjs-dist-legacy 500s every tool route in
// `next dev --turbopack`. Alias it to an empty stub — it's never called in
// the browser. Production (webpack, below) already stubs it via IgnorePlugin.
turbopack: {
resolveAlias: {
canvas: './src/lib/stubs/empty.ts',
},
},
// Webpack configuration for WASM modules
webpack: (config, { isServer, webpack }) => {
// Handle modules that use Node.js built-ins
if (!isServer) {
config.resolve.fallback = {
...config.resolve.fallback,
fs: false,
path: false,
crypto: false,
module: false,
url: false,
worker_threads: false,
canvas: false,
};
} else {
config.externals = config.externals || [];
config.externals.push({
canvas: 'commonjs canvas',
});
}
config.resolve.alias = {
...config.resolve.alias,
'module': false,
};
config.plugins.push(
new webpack.IgnorePlugin({
resourceRegExp: /^module$/
}),
new webpack.IgnorePlugin({
resourceRegExp: /^canvas$/,
contextRegExp: /pdfjs-dist-legacy/
})
);
// Enable WebAssembly
config.experiments = {
...config.experiments,
asyncWebAssembly: true,
};
return config;
},
};
export default withNextIntl(nextConfig);