mirror of
https://github.com/microsoft/monaco-editor.git
synced 2025-12-22 16:15:41 +01:00
Adding an example with the monaco webpack plugin (#42)
Adding an example with the monaco webpack plugin
This commit is contained in:
commit
e5f64ddfef
7 changed files with 4320 additions and 0 deletions
1
browser-esm-webpack-monaco-plugin/.gitignore
vendored
Normal file
1
browser-esm-webpack-monaco-plugin/.gitignore
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
dist/*.js
|
||||
12
browser-esm-webpack-monaco-plugin/dist/index.html
vendored
Normal file
12
browser-esm-webpack-monaco-plugin/dist/index.html
vendored
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<script src="./main.bundle.js"></script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
21
browser-esm-webpack-monaco-plugin/index.html
Normal file
21
browser-esm-webpack-monaco-plugin/index.html
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h2>Monaco Editor Webpack Plugin Sample</h2>
|
||||
|
||||
To run this sample, you need to:
|
||||
|
||||
<pre>
|
||||
$/browser-esm-webpack> npm install .
|
||||
$/browser-esm-webpack> ./node_modules/.bin/webpack
|
||||
</pre>
|
||||
|
||||
Then, <a href="./dist">open the ./dist folder</a>.
|
||||
|
||||
</body>
|
||||
</html>
|
||||
20
browser-esm-webpack-monaco-plugin/index.js
Normal file
20
browser-esm-webpack-monaco-plugin/index.js
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
import * as monaco from "monaco-editor/esm/vs/editor/editor.api";
|
||||
|
||||
(function () {
|
||||
// create div to avoid needing a HtmlWebpackPlugin template
|
||||
const div = document.createElement('div');
|
||||
div.id = 'root';
|
||||
div.style = 'width:800px; height:600px; border:1px solid #ccc;';
|
||||
|
||||
document.body.appendChild(div);
|
||||
})();
|
||||
|
||||
monaco.editor.create(
|
||||
document.getElementById('root'),
|
||||
{
|
||||
value: `const foo = () => 0;`,
|
||||
language: 'javascript',
|
||||
theme: 'vs-dark'
|
||||
}
|
||||
);
|
||||
|
||||
4220
browser-esm-webpack-monaco-plugin/package-lock.json
generated
Normal file
4220
browser-esm-webpack-monaco-plugin/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load diff
24
browser-esm-webpack-monaco-plugin/package.json
Normal file
24
browser-esm-webpack-monaco-plugin/package.json
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
{
|
||||
"name": "monaco",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1",
|
||||
"build": "webpack --progress"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
"devDependencies": {
|
||||
"css-loader": "^3.2.0",
|
||||
"file-loader": "^4.2.0",
|
||||
"monaco-editor-webpack-plugin": "^1.7.0",
|
||||
"style-loader": "^1.0.0",
|
||||
"webpack": "^4.39.2",
|
||||
"webpack-cli": "^3.3.6"
|
||||
},
|
||||
"dependencies": {
|
||||
"monaco-editor": "^0.16.2"
|
||||
}
|
||||
}
|
||||
22
browser-esm-webpack-monaco-plugin/webpack.config.js
Normal file
22
browser-esm-webpack-monaco-plugin/webpack.config.js
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
const path = require("path");
|
||||
const MonacoWebpackPlugin = require("monaco-editor-webpack-plugin");
|
||||
|
||||
module.exports = {
|
||||
mode: process.env.NODE_ENV,
|
||||
entry: "./index.js",
|
||||
output: {
|
||||
path: path.resolve(__dirname, "dist"),
|
||||
filename: "[name].bundle.js",
|
||||
},
|
||||
module: {
|
||||
rules: [{
|
||||
test: /\.css$/,
|
||||
use: ["style-loader", "css-loader",],
|
||||
}],
|
||||
},
|
||||
plugins: [
|
||||
new MonacoWebpackPlugin({
|
||||
languages: ["typescript", "javascript", "css"],
|
||||
})
|
||||
]
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue