mirror of
https://github.com/microsoft/monaco-editor.git
synced 2025-12-22 19:42:56 +01:00
Merge pull request #122 from gavinxgu/pr/custom_language_entry
feat: custom language support and absolute entry fallback
This commit is contained in:
commit
7443e5ef84
1 changed files with 12 additions and 2 deletions
14
src/index.ts
14
src/index.ts
|
|
@ -31,7 +31,11 @@ function resolveMonacoPath(filePath: string): string {
|
||||||
try {
|
try {
|
||||||
return require.resolve(path.join('monaco-editor/esm', filePath));
|
return require.resolve(path.join('monaco-editor/esm', filePath));
|
||||||
} catch(err) {
|
} catch(err) {
|
||||||
return require.resolve(path.join(process.cwd(), 'node_modules/monaco-editor/esm', filePath));
|
try {
|
||||||
|
return require.resolve(path.join(process.cwd(), 'node_modules/monaco-editor/esm', filePath));
|
||||||
|
} catch(err){
|
||||||
|
return require.resolve(filePath);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -71,6 +75,11 @@ interface IMonacoEditorWebpackPluginOpts {
|
||||||
*/
|
*/
|
||||||
languages?: EditorLanguage[];
|
languages?: EditorLanguage[];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Custom languages (outside of the ones shipped with the `monaco-editor`).
|
||||||
|
*/
|
||||||
|
customLanguages?: IFeatureDefinition[];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Include only a subset of the editor features.
|
* Include only a subset of the editor features.
|
||||||
* Use e.g. '!contextmenu' to exclude a certain feature.
|
* Use e.g. '!contextmenu' to exclude a certain feature.
|
||||||
|
|
@ -105,9 +114,10 @@ class MonacoEditorWebpackPlugin implements webpack.Plugin {
|
||||||
|
|
||||||
constructor(options: IMonacoEditorWebpackPluginOpts = {}) {
|
constructor(options: IMonacoEditorWebpackPluginOpts = {}) {
|
||||||
const languages = options.languages || Object.keys(languagesById);
|
const languages = options.languages || Object.keys(languagesById);
|
||||||
|
const customLanguages = options.customLanguages || [];
|
||||||
const features = getFeaturesIds(options.features || []);
|
const features = getFeaturesIds(options.features || []);
|
||||||
this.options = {
|
this.options = {
|
||||||
languages: coalesce(languages.map(id => languagesById[id])),
|
languages: coalesce(languages.map(id => languagesById[id])).concat(customLanguages),
|
||||||
features: coalesce(features.map(id => featuresById[id])),
|
features: coalesce(features.map(id => featuresById[id])),
|
||||||
filename: options.filename || "[name].worker.js",
|
filename: options.filename || "[name].worker.js",
|
||||||
publicPath: options.publicPath || '',
|
publicPath: options.publicPath || '',
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue