mirror of
https://github.com/microsoft/monaco-editor.git
synced 2025-12-22 05:50:11 +01:00
Adds vite esm example (#5094)
This commit is contained in:
parent
b62a81677f
commit
d38215cf6b
8 changed files with 1743 additions and 0 deletions
2
samples/browser-esm-vite/.gitignore
vendored
Normal file
2
samples/browser-esm-vite/.gitignore
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
dist
|
||||||
|
src/**/*.js
|
||||||
12
samples/browser-esm-vite/index.html
Normal file
12
samples/browser-esm-vite/index.html
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
|
<title>browser-esm-vite</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div id="root"></div>
|
||||||
|
<script type="module" src="/main.ts"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
13
samples/browser-esm-vite/main.ts
Normal file
13
samples/browser-esm-vite/main.ts
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
import './style.css';
|
||||||
|
import * as monaco from '../../src/editor/editor.main';
|
||||||
|
|
||||||
|
monaco.languages.register({ id: 'typescript' });
|
||||||
|
|
||||||
|
const tm = monaco.editor.createModel(`class Test {}`, 'typescript',
|
||||||
|
monaco.Uri.parse('file:///main.ts'));
|
||||||
|
|
||||||
|
const editor = monaco.editor.create(document.getElementById('root')!, {
|
||||||
|
model: tm,
|
||||||
|
language: 'typescript',
|
||||||
|
theme: 'vs-dark',
|
||||||
|
});
|
||||||
1664
samples/browser-esm-vite/package-lock.json
generated
Normal file
1664
samples/browser-esm-vite/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load diff
14
samples/browser-esm-vite/package.json
Normal file
14
samples/browser-esm-vite/package.json
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
{
|
||||||
|
"name": "browser-esm-vite",
|
||||||
|
"scripts": {
|
||||||
|
"dev": "vite",
|
||||||
|
"build": "tsc && vite build",
|
||||||
|
"serve": "vite preview"
|
||||||
|
},
|
||||||
|
"dependencies": {},
|
||||||
|
"devDependencies": {
|
||||||
|
"monaco-editor": "^0.54.0",
|
||||||
|
"typescript": "^5.9.3",
|
||||||
|
"vite": "^7.1.9"
|
||||||
|
}
|
||||||
|
}
|
||||||
8
samples/browser-esm-vite/style.css
Normal file
8
samples/browser-esm-vite/style.css
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
html,
|
||||||
|
body,
|
||||||
|
#root {
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
11
samples/browser-esm-vite/tsconfig.json
Normal file
11
samples/browser-esm-vite/tsconfig.json
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"target": "ESNext",
|
||||||
|
"strict": true,
|
||||||
|
"module": "ESNext",
|
||||||
|
"jsx": "react-jsx",
|
||||||
|
"moduleResolution": "node",
|
||||||
|
"allowSyntheticDefaultImports": true
|
||||||
|
},
|
||||||
|
"include": ["./"]
|
||||||
|
}
|
||||||
19
samples/browser-esm-vite/vite.config.ts
Normal file
19
samples/browser-esm-vite/vite.config.ts
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
import { defineConfig } from 'vite';
|
||||||
|
import { join } from 'path';
|
||||||
|
|
||||||
|
export default defineConfig({
|
||||||
|
server: {
|
||||||
|
fs: {
|
||||||
|
allow: ['../../', '../../../vscode']
|
||||||
|
}
|
||||||
|
},
|
||||||
|
resolve: {
|
||||||
|
alias: [{
|
||||||
|
find: 'monaco-editor-core/esm/vs',
|
||||||
|
replacement: join(__dirname, '../../../vscode/src/vs')
|
||||||
|
}, {
|
||||||
|
find: 'monaco-editor-core',
|
||||||
|
replacement: join(__dirname, '../../../vscode/src/vs/editor/editor.main.ts')
|
||||||
|
}],
|
||||||
|
}
|
||||||
|
});
|
||||||
Loading…
Add table
Add a link
Reference in a new issue