J
J
Juniorrrrr2020-08-18 09:41:19
JavaScript
Juniorrrrr, 2020-08-18 09:41:19

How to run two separate files on different ports?

There are two entry points.

  1. main.js
  2. index.js


and there are two html files

  1. main.html
  2. index.html


When building, I have connected js files to Html. index.js is connected to index.html and so on.

The task is to create two commands in the package.json file
start-index - runs the index.html file on port 3000
start-main runs the main.html file on port 8080

Each of them should run a different Html with different connected files on different ports.

Please tell me how to do this or in which direction to dig?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Belyaev, 2020-08-18
@Juniorrrrr

webpack.config.js:

const PORT = process.env.npm_lifecycle_event === 'start-main' ? 8080 : 3000;
// дальше просто выдавайте разные конфиги webpack

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question