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

308
Vistas
Paquete web: generación de dos archivos diferentes para el mismo archivo js

Soy nuevo en webpack. Estoy usando node.js como servidor y quiero que el servidor envíe un archivo como respuesta. Para ruta / quiero enviar index.html , para ruta /other quiero enviar other.html , y así sucesivamente...

Por el momento, todos los archivos html llaman a los archivos js usando <script> . Por ejemplo, index.html contiene <script src='../index.js'></script> .

Hace unos días me presentaron con webpack. La configuración de mi paquete web es la siguiente

 const path = require('path') const HtmlWebpackPlugin = require('html-webpack-plugin'); const { CleanWebpackPlugin } = require("clean-webpack-plugin"); const commonHtmlPluginProps = { inject: false, minify: { removeAttributeQuotes: true, minifyJS: true, removeComments: true, collapseBooleanAttributes: true, collapseWhitespace: true, sortClassName: true } } module.exports = { mode: 'production', entry: { // index: './src/index.js', // another: './src/another.js', // other: './src/other.js', index: './src/html/index.html', another: './src/html/another.html', other: './src/html/other.html', }, plugins: [ new CleanWebpackPlugin(), new HtmlWebpackPlugin({ template: path.resolve(__dirname, 'src', 'html', 'index.html'), ouptutName: 'index.html', ...commonHtmlPluginProps, }), new HtmlWebpackPlugin({ template: path.resolve(__dirname, 'src', 'html', 'another.html'), filename: 'another.html', ...commonHtmlPluginProps, }), new HtmlWebpackPlugin({ template: path.resolve(__dirname, 'src', 'html', 'other.html'), filename: 'other.html', ...commonHtmlPluginProps, }), ], module: { rules: [ { test: /\.html$/, use: ['html-loader'] } ], }, output: { path: path.resolve(__dirname, 'dist'), filename: 'js/[name].[contenthash].js' }, }

y tengo la siguiente estructura de archivos

estructura de directorios

Cada vez que reconstruyo el proyecto, obtengo dos copias de los archivos js, aunque mi entrada sea de archivos html.

¿Dónde me equivoco? Sugiérame una mejor manera. ¡Gracias por adelantado!

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