我正在尝试找出一种简单的方法,在脚本中需要 html 模板,然后从 CLI 运行 browserify。
假设我想获取一个模板并将其附加到正文中。
//index.js
var template = require('./template.html');
document.body.appendChild(template);
and
<!-- template.html -->
<p>Woooo!</p>
然后使用 CLI 将其全部封装在 Browserify 中。
browserify index.js > build.js
在引用的浏览器中加载index.html模板时build.js
我在控制台中收到此错误:
Uncaught SyntaxError: Unexpected token <
这是引用
....
},{}],3:[function(require,module,exports){
<div class="slide">
<h2 data-slide-title></h2>
<div data-slide-copy></div>
</div>
},{}]},{},[1])