Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

125
Views
How to setup WebPack dynamic output dir?

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',
      },
    ],
  },
};
about 4 years ago · Santiago Gelvez
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!