How to open browser to localhost through npm scripts

后端 未结 4 1299
眼角桃花
眼角桃花 2020-12-28 15:38

I\'ve been trying to figure out how to write a npm script that will culminate with the application being launched in the user\'s browser without them having to

4条回答
  •  情歌与酒
    2020-12-28 15:53

    If You use Webpack There is another way to do this using the webpack-dev-server

    • Install it using npm install webpack-dev-server --save-dev
    • Then run webpack-dev-server or configure npm script like this :
      "start": "webpack-dev-server"

    • Then navigate to http://localhost:8080

    It serve per default files in the current directory. If you want to serve files from another directory you need to use the --content-base option like this:

    webpack-dev-server --content-base thefolderyouwanttoserve/
    

    More about webpack-dev-server here in the official webpack doc.

提交回复
热议问题