【发布时间】:2017-10-10 14:03:45
【问题描述】:
我有充满任意 css/html/js/image 文件的模板文件夹。我希望能够通过 require 访问它们:
var someHtml = require('./templateFolder/foo.html');
这里,foo.html 包含对 foo.png、foo.css 和 foo.js 的引用,我希望它们都内联在 html 文档本身中,分别以 base64 编码、样式标记和脚本标记。这可能吗?如果是这样,webpack 配置会是什么样子?
编辑:进一步的上下文
我想要这个
<html>
<head>
<link rel="stylesheet" type="text/css" href="foo.css">
<script type="text/javascript" src="bar.js"></script>
</head>
<body>
</body
</html>
变成这样:
<html>
<head>
<style> Contents of foo.css </style>
<script> Contents of bar.js</script>
</head>
<body>
</body
</html>
换句话说,我希望将每个 html 文件及其所有资源转换为单个 html 文件。对于 html 文件的外观,我不一定有很多控制权。
【问题讨论】:
标签: javascript html css webpack