门户热部署live-server

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接: https://blog.csdn.net/qq_45042013/article/details/102745591

没有webpack,我们就无法使用webpack-dev-server运行这个项目,实现热部署。

使用另外一种热部署方式:live-server,这是一款带有热加载功能的小型开发服务器。用它来展示你的HTML / JavaScript / CSS,但不能用于部署最终的网站

地址https://www.npmjs.com/package/live-server

1、安装,使用npm命令即可,这里建议全局安装,以后任意位置可用(管理员方式安装):

npm install -g live-server

运行时,直接输入命令(可以自己配置脚步启动端口):

live-server

测试:

live-server --port=9002

2、脚本启动,初始化npm

npm init -y

安装vue

npm install vue --save

配置启动脚本:

进入package.json文件,在script中添加启动脚本:

{
  "name": "leyou-portal",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "serve": "live-server --port=9002"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "vue": "^2.6.10"
  }
}

猜你喜欢

转载自blog.csdn.net/qq_45042013/article/details/102745591