-
-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unexpected character '' error #174
Comments
@croxywastaken To import a TTF file in Next.js, you need to configure the appropriate loader in the Here is an example module.exports = {
webpack: (config, { isServer }) => {
// Add a loader for TTF files
config.module.rules.push({
test: /\.(woff|woff2|eot|ttf|otf)$/,
use: {
loader: 'file-loader',
options: {
name: '[name].[ext]',
publicPath: '/_next/static/fonts',
outputPath: 'static/fonts',
esModule: false,
},
},
});
// Configure behavior when importing TTF files on the server-side
if (isServer) {
const originalEntry = config.entry;
config.entry = async () => {
const entries = await originalEntry();
if (entries['main.js'] && !entries['main.js'].includes('./utils/fix-ttf-import.js')) {
entries['main.js'].unshift('./utils/fix-ttf-import.js');
}
return entries;
};
}
return config;
},
}; This configuration file does the following:
Additionally, you need to create a file named if (typeof window !== 'undefined') {
require('monaco-editor/min/vs/base/browser/ui/codicons/codicon/codicon.ttf');
} This file is responsible for importing the TTF file on the browser-side. Please note that the above configuration is suitable for Next.js version 10 and above. If you are using an older version, refer to the respective documentation or community resources for the appropriate configuration method. |
My code: import React, { useEffect, useRef, useState } from "react";
import MonacoEditor from '@uiw/react-monacoeditor';
function App() {
const [code, setCode] = useState('')
return (
<>
<div className="bg-white marker:shadow-lg flex flex-col text-sm select-none">
<main className="bg-dark-700">
<div className="main-content">
<div className="bg-gray-1">
<MonacoEditor
language="html"
value="<h1>I ♥ react-monacoeditor</h1>"
options={{
theme: 'vs-dark',
}}
/>
</div>
</div>
</main>
</div>
</>
);
}
export default App; |
Btw, i'm using this module on electron app. (next.js + electron) |
my packages:
"electron": "^21.3.3",
"electron-builder": "^23.6.0",
"next": "^12.3.4",
"nextron": "^8.7.0",
"react": "^18.2.0",
"react-dom": "^18.2.0"
"@uiw/react-monacoeditor": "^3.5.9",
how can i fix this?
The text was updated successfully, but these errors were encountered: