Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

126
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda