gpt4 book ai didi

javascript - Webpack插件看子编译

转载 作者:搜寻专家 更新时间:2023-11-01 00:23:58 25 4
gpt4 key购买 nike

插件compiles an additional assetemit 阶段:

MyPlugin.prototype.apply = function(compiler) {
compiler.plugin('emit', function(compilation, callback) {
var outputOptions = {
filename: 'output.js',
publicPath: compilation.outputOptions.publicPath
};
var childCompiler = compilation.createChildCompiler('MyPluginCompilation', outputOptions);
childCompiler.apply(new NodeTemplatePlugin(outputOptions));
childCompiler.apply(new LibraryTemplatePlugin('result', 'var'));
childCompiler.apply(new NodeTargetPlugin());
childCompiler.apply(new SingleEntryPlugin(this.context, 'my-loader!input.js'));
childCompiler.runAsChild(callback);
});
};

这非常有效,但是当使用 webpack-dev-server 时,webpack 不会监视指定的 'input.js' 文件。

我如何设置我的 webpack 子编译以在文件更改时重新编译?

最佳答案

监视在 after-compile 步骤开始,它在 before emit 运行,因此您的子编译器的文件依赖项永远不会添加到要查看的文件列表。

您应该使用make 而不是emit。这是 recommended interface用于将条目和模块添加到您的编译中。

关于javascript - Webpack插件看子编译,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30343961/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com