[英]webpack separate build files
I have a nested directory structure with jsx modules, like app/js/header/index.jsx app/js/task/runner.jsx and so on 我有一个包含jsx模块的嵌套目录结构,例如app / js / header / index.jsx app / js / task / runner.jsx等
is it possible to have webpack transpile each one of them and output the result in the same directory as the jsx file? 是否有可能让webpack转换它们中的每一个并将结果输出到与jsx文件相同的目录中?
Regards 问候
If I understand you correctly, you want to put resulting module next to each source module. 如果我对您的理解正确,则要将结果模块放在每个源模块旁边。 It seems that you can achieve this with a plugin: 看来您可以使用插件来实现:
var fs = require('fs');
function MyPlugin() {}
MyPlugin.prototype.apply = function(compiler) {
compiler.plugin('emit', function(compilation, callback) {
compilation.modules.forEach(m => {
if (/filename/.test(m.resource)) { // test for filename to exclude node_modules
fs.writeFileSync(m.resource + '.transpiled', m._source._value);
}
});
callback();
});
};
and in the webpack config: 并在webpack配置中:
{
...
plugins: [ MyPlugin() ],
...
}
Is it what you are trying to do? 这是您要做什么?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.