UNPKG

monaco-editor-esm-webpack-plugin

Version:

The webpack's plugin for monaco editor to compile the worker and handle with localization

24 lines (20 loc) 984 B
const MonacoEditorWebapckPlugin = require('monaco-editor-webpack-plugin'); const NormalModuleWebpackReplacementPlugin = require("webpack/lib/NormalModuleReplacementPlugin"); const nls = require.resolve('monaco-editor-nls'); function MonacoEditorEsmWebpackPlugin({ isMonacoEditorWebapckPlugin = true, isReplaceNls = true, ...options } = {}) { if(isMonacoEditorWebapckPlugin) { this.plugin1 = new MonacoEditorWebapckPlugin(options); } if(isReplaceNls) { this.plugin2 = new NormalModuleWebpackReplacementPlugin(/\/(vscode\-)?nls\.js/, function(resource) { resource.request = nls; resource.resource = nls; }); } } MonacoEditorEsmWebpackPlugin.prototype.apply = function(compiler) { this.plugin1 && this.plugin1.apply(compiler); this.plugin2 && this.plugin2.apply(compiler); } MonacoEditorEsmWebpackPlugin.loader = require.resolve('./loader'); module.exports = MonacoEditorEsmWebpackPlugin;