Varsh
Varsh

Reputation: 465

Run html web page using npm package.json

I am very new to package.json related files. I have designed one HTML web page. I am using 3 files HTML,CSS and js. Now I am running HTML file by directly opening it into the browser. I am suggested to do this with package.json file and npm and create a link so that others can also access this web page. Can anybody please help me with this. This is a very basic question but finding difficult to do. Can somebody help me with this? Using Ubuntu 18.04, HTML5, CSS3, bootstrap 3.4.0

Upvotes: 6

Views: 5669

Answers (1)

T04435
T04435

Reputation: 13992

For a long time I did use Browsersync

Install

npm install -g browser-sync

Start it

browser-sync start --server --files "css/*.css"

You can find more Docs on the above link.

So if you don't have a package.json you can do npm init on the root of the project.

Then on your package.json under scripts:

{
  ...,
  dev: browser-sync start --server --files "css/*.css",
  share: browser-sync start --proxy "myproject.dev" --files "css/*.css"
}

So dev you can use it for local development and share to share with others for feedback...

npm run dev
npm run share

Upvotes: 2

Related Questions