-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
next.config.js
64 lines (62 loc) · 2.43 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
54
55
56
57
58
59
60
61
62
63
64
import MonacoWebpackPlugin from 'monaco-editor-webpack-plugin';
import { patchWebpackConfig } from 'next-global-css';
/** @type {import('next').NextConfig} */
const nextConfig = {
eslint: {
ignoreDuringBuilds: true,
},
trailingSlash: true,
webpack(config, options) {
// this fixes some issues with loading web workers
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)
// this import has moved a bit, so let's make it absolute from the module path
'monaco-editor/esm/vs/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: 'monaco-graphql/esm/graphql.worker.js',
},
},
// TOD: webpack monaco editor plugin breaks on languages: ['typescript']
// so this was necessary
// see: https://github.com/microsoft/monaco-editor/issues/2738
{
label: 'typescript',
worker: {
id: 'typescript',
entry: 'monaco-editor/esm/vs/language/typescript/ts.worker.js',
},
},
],
}),
);
}
// load monaco-editor provided ttf fonts
config.module.rules.push({ test: /\.ttf$/, type: 'asset/resource' });
return config;
},
};
export default nextConfig;