Merge pull request #18 from timkendrick/fix/worker-output-path

Fix worker output path in loader rules
This commit is contained in:
Alexandru Dima 2018-06-13 10:58:40 +02:00 committed by GitHub
commit 7e67afdc3d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 5 deletions

View file

@ -1,6 +1,6 @@
# Monaco Editor Webpack Loader Plugin
A plugin to simplify loading the [Monaco Editor](https://github.com/Microsoft/monaco-editor) with [webpack](https://webpack.js.org/) contributed by [Tim Kendrik](https://github.com/timkendrick).
A plugin to simplify loading the [Monaco Editor](https://github.com/Microsoft/monaco-editor) with [webpack](https://webpack.js.org/).
## Installing
```sh
@ -38,7 +38,7 @@ monaco.editor.create(document.getElementById('container'), {
Options can be passed in to `MonacoWebpackPlugin`. They can be used to generate a smaller editor bundle by selecting only certain languages or only certain editor features:
* `output` (`string`) - append a certain string to all generated files.
* `output` (`string`) - custom output path for worker scripts, relative to the main webpack `output.path`.
* default value: `''`.
* `languages` (`string[]`) - include only a subset of the languages supported.
* default value: `['bat', 'coffee', 'cpp', 'csharp', 'csp', 'css', 'dockerfile', 'fsharp', 'go', 'handlebars', 'html', 'ini', 'java', 'json', 'less', 'lua', 'markdown', 'msdax', 'mysql', 'objective', 'pgsql', 'php', 'postiats', 'powershell', 'pug', 'python', 'r', 'razor', 'redis', 'redshift', 'ruby', 'sb', 'scss', 'solidity', 'sql', 'swift', 'typescript', 'vb', 'xml', 'yaml']`.

View file

@ -61,7 +61,7 @@ class MonacoWebpackPlugin {
const workers = modules.map(
({ label, alias, worker }) => worker && ({ label, alias, ...worker })
).filter(Boolean);
const rules = createLoaderRules(languages, features, workers, publicPath);
const rules = createLoaderRules(languages, features, workers, output, publicPath);
const plugins = createPlugins(workers, output);
addCompilerRules(compiler, rules);
addCompilerPlugins(compiler, plugins);
@ -83,11 +83,11 @@ function getPublicPath(compiler) {
return compiler.options.output && compiler.options.output.publicPath || '';
}
function createLoaderRules(languages, features, workers, publicPath) {
function createLoaderRules(languages, features, workers, outputPath, publicPath) {
if (!languages.length && !features.length) { return []; }
const languagePaths = languages.map(({ entry }) => entry).filter(Boolean);
const featurePaths = features.map(({ entry }) => entry).filter(Boolean);
const workerPaths = fromPairs(workers.map(({ label, output }) => [label, output]));
const workerPaths = fromPairs(workers.map(({ label, output }) => [label, path.join(outputPath, output)]));
const globals = {
'MonacoEnvironment': `(function (paths) {