my1.html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no"/>
<meta name="format-detection" content="telephone=no"/>
</head>
<body>
<div>
巴拉巴拉1
</div>
<script src="js/my1.js"></script>
</body>
</html>
my2.html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no"/>
<meta name="format-detection" content="telephone=no"/>
</head>
<body>
<div>
巴拉巴拉2
</div>
<script src="js/my2.js"></script>
</body>
</html>
这需要webpack打包么?我觉得不是很有必要啊...
webpack 是一个 module bundler,其实要解决的核心问题是基于 CommonJS 规范定义的模块如何在页面上运行的问题(commonJS 的模块在页面上无法直接运行)。那么假设你的代码,根本没有模块化的内容,你只是一个很单纯的 js 实现,那你完全没有必要使用 webpack,甚至即使你是 AMD 规范定义的模块,你也不是必须使用 webpack,原有 requireJS 在浏览器端处理依赖的方式仍然可行。