-
Notifications
You must be signed in to change notification settings - Fork 0
/
next.config.js
53 lines (50 loc) · 1.96 KB
/
next.config.js
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
const MonacoWebpackPlugin = require("monaco-editor-webpack-plugin");
const { patchWebpackConfig } = require("next-global-css");
const path = require.path;
/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: true,
trailingSlash: true,
webpack(config, options) {
// this fixes some issues with loading webworkers
config.output.publicPath = "/_next/";
// because next.js doesn't like node_modules that import css files
// this solves the issue for monaco-editor, which relies on importing css files
patchWebpackConfig(config, options);
config.resolve.alias = {
...config.resolve.alias,
// this solves a bug with more recent `monaco-editor` versions in next.js,
// where vscode contains a version of `marked` with modules pre-transpiled, which seems to break the build.
//
// (the error mentions that exports.Lexer is a const that can't be re-declared)
"../common/marked/marked.js": "marked",
};
if (!options.isServer) {
config.plugins.push(
// if you find yourself needing to override
// MonacoEnvironment.getWorkerUrl or MonacoEnvironment.getWorker,
// you probably just need to tweak configuration here.
new MonacoWebpackPlugin({
// you can add other languages here as needed
languages: ["json", "graphql"],
filename: "static/[name].worker.js",
// this is not in the plugin readme, but saves us having to override
// MonacoEnvironment.getWorkerUrl or similar.
customLanguages: [
{
label: "graphql",
worker: {
id: "graphql",
entry: require.resolve("monaco-graphql/esm/graphql.worker.js"),
},
},
],
})
);
}
// load monaco-editor provided ttf fonts
config.module.rules.push({ test: /\.ttf$/, type: "asset/resource" });
return config;
},
};
module.exports = nextConfig;