Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

142
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda