【问题标题】:Compiling HTML, CSS, and JS, into a single JS file将 HTML、CSS 和 JS 编译成一个 JS 文件
【发布时间】:2019-10-15 15:57:14
【问题描述】:

有没有合适的程序将htmlcssjs文件编译一个js文件?我一直在寻找如何将csshtml 文件加载到js 的方法,它们都需要requireJS。有没有 webpack 插件,或者只是一个模块?

我知道这不是一个体面的问题,但我一直在考虑不要总是获取外部源文件(htmlcss)。

例子:

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Blah blah blah</title>
    <script src="something.js"></script>
    <script>
        // 'load' will load everthing to #something
        something.load(
            // options
        )
    </script>
</head>

<body>
    <div id="something"></div>
</body>

</html>

【问题讨论】:

  • 这些都可以放入 HTML 文件中。当然,最好使用外部资源,因为它们是缓存的。
  • 你应该获取外部资源。
  • 我完全理解你们。但我需要 JS 文件来加载所有内容(css 和 html)。使用 requireJS 完全可行,我正在考虑没有 requireJS 的选项。

标签: javascript html css webpack requirejs


【解决方案1】:

最后,感谢article,我只需要html-loader。然后我可以添加import html from 'some.html'

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-07-19
    • 2018-09-27
    • 1970-01-01
    • 2021-08-16
    • 1970-01-01
    • 2021-08-19
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多