mirror of
https://github.com/microsoft/monaco-editor.git
synced 2025-12-22 16:15:41 +01:00
Add webpack loader plugin
This commit is contained in:
parent
32f5433657
commit
7d6ae1b4f3
8 changed files with 1144 additions and 0 deletions
27
webpack/plugins/AddWorkerEntryPointPlugin.js
Normal file
27
webpack/plugins/AddWorkerEntryPointPlugin.js
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
class AddWorkerEntryPointPlugin {
|
||||
constructor(webpack, { id, entry, output }) {
|
||||
this.webpack = webpack;
|
||||
this.options = { id, entry, output };
|
||||
}
|
||||
|
||||
apply(compiler) {
|
||||
const webpack = this.webpack;
|
||||
const { id, entry, output } = this.options;
|
||||
compiler.plugin('make', (compilation, callback) => {
|
||||
const outputOptions = {
|
||||
filename: output,
|
||||
publicPath: compilation.outputOptions.publicPath,
|
||||
// HACK: globalObject is necessary to fix https://github.com/webpack/webpack/issues/6642
|
||||
globalObject: 'this',
|
||||
};
|
||||
const childCompiler = compilation.createChildCompiler(id, outputOptions, [
|
||||
new webpack.webworker.WebWorkerTemplatePlugin(),
|
||||
new webpack.LoaderTargetPlugin('webworker'),
|
||||
new webpack.SingleEntryPlugin(this.context, entry, 'main'),
|
||||
]);
|
||||
childCompiler.runAsChild(callback);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = AddWorkerEntryPointPlugin;
|
||||
Loading…
Add table
Add a link
Reference in a new issue