10、webpack开发--自动编译源代码
程序员文章站
2024-03-14 20:24:47
...
如果我们更改了源代码,而不像每次都要运行npm run build,该如何办呢?
1、更改package.json文件,scripts追加"watch": "webpack --watch"开启webpack watch模式
{
"name": "webpack-demo",
"version": "1.0.0",
"description": "",
"private": true,
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build": "webpack",
"watch": "webpack --watch"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"clean-webpack-plugin": "^2.0.2",
"css-loader": "^2.1.1",
"csv-loader": "^3.0.2",
"file-loader": "^3.0.1",
"html-webpack-plugin": "^3.2.0",
"style-loader": "^0.23.1",
"webpack": "^4.32.0",
"webpack-cli": "^3.3.2",
"xml-loader": "^1.2.1"
},
"dependencies": {
"lodash": "^4.17.11"
}
}
2、watch模式运行
npm run watch
3、运行效果
4、修改print.js文件
export default function print() {
// console.error('code find a error!'); 修改前
console.log('code was updated!');
}
5、刷新页面,运行效果如下:
上一篇: MacOS 安装配置jdk
下一篇: LINUX下安装jdk1.8
推荐阅读
-
10、webpack开发--自动编译源代码
-
debian 源代码编译_如何在Debian 10上从源代码安装phpMyAdmin
-
配置vim为php开发编译器增加导航自动提示
-
linux下apache+mysql+php开发环境纯源代码编译搭建
-
玩转安卓10源码开发定制 编译Windows平台adb和fastboot工具
-
linux下apache+mysql+php开发环境纯源代码编译搭建
-
基于WIN10系统的OpenCV3.4.0+Python2.7+Visual Studio 2017编译开发环境搭建
-
win10通过samba实现在主机中开发虚拟机中编译
-
(精华)2020年7月10日 webpack html文件的编译
-
如何在macOS中编译OpenJDK10源代码