webpack-dev-server的自动更新配置
一、背景
测试发布一个项目,修改jsx中的内容,页面不自动更新。
每次必须执行npm run build;然后执行npm run start。
脚本如下:
"scripts": {
"start": "webpack-dev-server --history-api-fallback --colors --no-info --open",
"build": "webpack"
},
build每次要花6秒左右,效率实在不高。
二、检查
1. webpack.config.js
module.exports = {
entry: './index.js',
output: {
path: path.join(__dirname, 'dist'),
filename: 'bundle.js'
}
看的出,运行文件打包成bundle.js,存放路径在dist目录下。
2. index.html
<script src="./dist/bundle.js"></script>
引用了生成的项目文件bundle.js。
三、原因
webpack-dev-server动态生成的包并不发布到你的真实目录中(dist/),而是放在了内存中。
四、解决
将项目的指向配置到虚拟服务器中。
修改index.html中的src路径为:
<script src="http://localhost:8080/bundle.js"></script>
五、测试
. 执行npm run build。
. 然后执行npm run start。
. 修改jsx文件,保存。
哈哈,自动更新了。
这些再也不用修改一个label命名也要重启了- -!
webpack-dev-server的自动更新配置的更多相关文章
- 笔记:配置 webpack dev server
笔记:配置 webpack dev server 安装 webpack-dev-server 组件 配置 webpack.config.js 配置 增加 html-webpack-plugin 组件 ...
- 配置Webpack Dev Server 实战操作方法步骤
本文摘要:配置 Webpack Dev Server 可以解决本地开发前端应用时,手动执行 webpack 命令或 yarn build 命令,再去浏览器中访问 dist/index.html 的麻烦 ...
- [Webpack] Access Webpack Dev Server from Mobile Safari on an iPhone
Testing your sites on mobile devices is a critical part of the development process. Webpack dev serv ...
- Spring Cloud Bus 自动更新配置
---恢复内容开始--- Spring Cloud Config 结合 Spring Cloud bus 实现 git 仓库提交配置文件 触发消息队列 应用自动更新配置 1. config 服务端 添 ...
- 带你入门SpringCloud 之 通过SpringCloud Bus 自动更新配置
前言 在<带你入门SpringCloud统一配置 | SpringCloud Config>中通过 SpringCloud Config 完成了统一配置基础环境搭建,但是并没有实现配置修改 ...
- ubuntu Server 14 自动更新
https://help.ubuntu.com/stable/serverguide/automatic-updates.html http://spin.atomicobject.com/2014/ ...
- Nacos 自动更新配置不生效问题
版本 Nacos 1.4.1 SpringCloud 2020.0.3 解决方案 bootstrap.properties 增加应用名配置即可 spring.application.name=serv ...
- webpack dev server 配置 启动项目报错Error: listen EADDRINUSE
Error: listen EADDRINUSE 0.0.0.0:5601 它的意思是,端口5601被其他进程占用. 切换端口即可解决问题
- Spring Cloud Bus实现自动更新配置
一.概述 1. 配置环境 版本:Spring Boot版本2.0.3.RELEASE,Spring Cloud版本Finchley.SR1,RabbitMQ 3.7.7 说明:本文章是在https:/ ...
随机推荐
- Kettle资源库采用SQLserver数据库需要注意的点
Kettle开源ETL工具有着自己的元数据存储方式,可以分为两种 1:File 2:DB 文件存储我这里就不多说了,下面说一下在用SQLserver2008 R2作为资源库在创建的过程中遇到的问题 K ...
- (LeetCode74)Search a 2D Matrix
Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the follo ...
- 把thinkphp项目拷贝到其他电脑上报错
提示 include(***\ThinkPHP\Library/Think/Log.class.php): failed to open stream 把Application\Runtime文件夹里 ...
- svg translate 操作
function dragElement(evt) { var target = evt.target; var id = target.id; var dx = evt.dx, dy = evt.d ...
- java面试第八天
异常: 异常的分类 Java会将所有的异常封装成对象,其根本父类为Throwable. Throwable有两个子类:Error 和Exception. Error:一个Error对象表示一个程序错误 ...
- 解压版MySQL安装后初始化root密码
1: C:\Users\gechong>mysql
- Deep compression code
https://github.com/songhan/SqueezeNet-Deep-Compression import sys import os import numpy as np impor ...
- MySQL Event计划任务刷慢日志
前言 最近在尝试一个日志系统graylog来收集mysql的慢查询日志提,供后续的分析.监控和报警等.测试步骤已经到日志已成功收集到graylog,测试时需要刷一些慢查询日志出来.为了刷比较多的日志和 ...
- 【转】Html.RenderPartial与 Html.RenderAction的区别
Html.RenderPartial与Html.RenderAction 这个两个方法都是用于把MVC用户控件嵌入到View中. Html.RenderPartial是直接将MVC用户控件嵌入到界面上 ...
- eclipse could not create the Java Vitual Machine
eclipse could not create the Java Vitual Machine CreateTime--2018年4月27日11:07:15 Author:Marydon 1.情 ...