I have this setup currently. The first three entries (app, blocks, react) compile as expected to the rootDir/prod/[name].min.js - This already works
I want the 4th entry (which is a dynamic one). I have this directory: rootDir/gutenberg/blocks/[blockNameDir]/frontend.js; I want the frontend.js file for each of the [blockNameDir] directories to be compiled to the same directory as frontend.min.js.
I figured out how to use the glob for the dynamic entry, but I am stuck at the dynamic output. Thanks in advance.
const path = require('path');
var glob = require('glob');
const outputDir = path.resolve(__dirname, 'prod');
module.exports = {
mode: 'development',
entry: {
app: path.resolve(__dirname, './src/js/app.js'),
blocks: path.resolve(__dirname, './gutenberg/blocks.js'),
react: path.resolve(__dirname, './src/js/app-react.js'),
frontend: glob.sync(
path.resolve(__dirname, './gutenberg/blocks/**/frontend.js')
),
},
devtool: 'inline-source-map',
output: {
path: outputDir,
filename: '[name].min.js',
},
devtool: 'source-map',
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: ['babel-loader'],
},
{
test: /\.js$/,
use: ['source-map-loader'],
enforce: 'pre',
},
],
},
};