Repository navigation
Expand file tree
/
Copy pathnext.config.js
More file actions
59 lines (55 loc) · 1.75 KB
/
Copy pathnext.config.js
File metadata and controls
59 lines (55 loc) · 1.75 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
const WasmPackPlugin = require('@wasm-tool/wasm-pack-plugin');
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
const { dirname, relative, resolve, join } = require('path');
const { withPlausibleProxy } = require('next-plausible');
module.exports = withPlausibleProxy()({
async headers() {
return [
{
source: '/api/flag.svg',
headers: [
{
key: 'Content-Type',
value: 'image/svg+xml',
},
],
},
];
},
async rewrites() {
return [
{
source: '/js/script.js',
destination: 'https://plausible.io/js/plausible.js',
},
{
source: '/api/event', // Or '/api/event/' if you have `trailingSlash: true` in this config
destination: 'https://plausible.io/api/event',
},
];
},
webpack: (config, { buildId, dev, isServer, defaultLoaders, webpack }) => {
// Important: return the modified config
config.experiments = {
asyncWebAssembly: true,
...config.experiments,
};
// In prod mode and in the server bundle (the place where this "chunks" bug
// appears), use the client static directory for the same .wasm bundle
config.output.webassemblyModuleFilename =
isServer && !dev ? '../static/wasm/[id].wasm' : 'static/wasm/[id].wasm';
// Ensure the filename for the .wasm bundle is the same on both the client
// and the server (as in any other mode the ID's won't match)
config.optimization.moduleIds = 'named';
if (process.env.ANALYZE) {
config.plugins.push(
new BundleAnalyzerPlugin({
analyzerMode: 'server',
analyzerPort: isServer ? 8888 : 8889,
openAnalyzer: true,
})
);
}
return config;
},
});