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

307
Views
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
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!