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

140
Vistas
How to set diffrent plugin options with webpack-merge

base https://webpack.js.org/guides/production/

I want to use diffrent html template in webpack.dev.js & webpack.prod.js

webpack.common.js

const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');

module.exports = {
    entry: {
        app: './src/index.js',
    },
    plugins: [
        new HtmlWebpackPlugin({
            title: 'Production'
        }),
    ]
};

webpack.dev.js

const { merge } = require('webpack-merge');
const common = require('./webpack.common.js');

module.exports = merge(common, {
    mode: 'development',
    plugins: [
        new HtmlWebpackPlugin({
            template:'./public/index-dev.html',
        })
    ]
});

webpack.prod.js

const { merge } = require('webpack-merge');
const common = require('./webpack.common.js');

module.exports = merge(common, {
    mode: 'production',
    plugins: 
        new HtmlWebpackPlugin({
            template:'./public/index.html',
        })
    ]
});

report ReferenceError: HtmlWebpackPlugin is not defined when npm run with these config

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

With out an explicit require/import you cann't directly access HtmlWebpackPlugin of anything else from one config file in another. Merge only joins the config portion not the whole files.

Therefor you must have const HtmlWebpackPlugin = require('html-webpack-plugin'); in all files where HtmlWebpackPlugin is used.

webpage-merge is does not merge all file data just the module.exports object itself.

about 4 years ago · Juan Pablo Isaza Denunciar
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