slint/tools/online_editor/webpack.common.js
Simon Hausmann 2041144f45 Fix a warning on start-up about freezing the UI
The console log would show

  "Could not create web worker(s). Falling back to loading web worker code
  in main thread, which might cause UI freezes. Please see
  https://github.com/Microsoft/monaco-editor#faq"

and

  "VM3793 simpleWorker.js:29 You must define a function
  MonacoEnvironment.getWorkerUrl or MonacoEnvironment.getWorker"

when loading. This is fixed by using the monaco editor webpack plugin, which
ensures that the workers are loaded via async script tags.
2020-10-06 10:21:15 +02:00

51 lines
1.5 KiB
JavaScript

const path = require('path');
const HtmlWebPackPlugin = require('html-webpack-plugin');
const WasmPackPlugin = require("@wasm-tool/wasm-pack-plugin");
const MonacoWebpackPlugin = require('monaco-editor-webpack-plugin');
const dist = path.resolve(__dirname, "dist");
module.exports = {
entry: {
app: './index.ts',
'editor.worker': 'monaco-editor/esm/vs/editor/editor.worker.js',
'json.worker': 'monaco-editor/esm/vs/language/json/json.worker',
'css.worker': 'monaco-editor/esm/vs/language/css/css.worker',
'html.worker': 'monaco-editor/esm/vs/language/html/html.worker',
'ts.worker': 'monaco-editor/esm/vs/language/typescript/ts.worker'
},
resolve: {
extensions: ['.ts', '.js']
},
output: {
globalObject: 'self',
filename: '[name].bundle.js',
path: dist
},
module: {
rules: [
{
test: /\.ts?$/,
use: 'ts-loader',
exclude: /node_modules/
},
{
test: /\.css$/,
use: ['style-loader', 'css-loader']
},
{
test: /\.ttf$/,
use: ['file-loader']
},
]
},
plugins: [
new HtmlWebPackPlugin({
title: 'SixtyFPS Online Editor',
template: 'index.html'
}),
new WasmPackPlugin({
crateDirectory: path.resolve(__dirname, "../../api/sixtyfps-wasm-interpreter/"),
}),
new MonacoWebpackPlugin(),
]
};