Is it possible to configure webpack to do the equivalent of:
babel src --watch --out-dir lib
So that a directory structure that looks like this
If you want to output to multiple directories, you can use the path as the entry name.
entry: {
'foo/f.js': __dirname + '/src/foo/f.js',
'bar/b.js': __dirname + '/src/bar/b.js',
},
output: {
path: path.resolve(__dirname, 'lib'),
filename: '[name]',
},
Therefore you can use a function to generate a list of entries for you that satisfy the above:
const glob = require('glob');
function getEntries(pattern) {
const entries = {};
glob.sync(pattern).forEach((file) => {
entries[file.replace('src/', '')] = path.join(__dirname, file);
});
return entries;
}
module.exports = {
entry: getEntries('src/**/*.js'),
output: {
path: path.resolve(__dirname, 'lib'),
filename: '[name]',
},
// ...
}