问题标签 [grunt-includes]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
gruntjs - 将 Grunt 用于基本包含
我有一个包含 3 页的应用程序,我希望它是独立的。为了 DRY 代码,我想对页眉和页脚内容进行“包含”。我查看了grunt-html-build的文档和示例,但不知何故我做不到。所有 HTML 都在 path'src/html'
中,includes 位于名为 "includes": 的子文件夹中'src/html/includes'
。
这是 HTML 示例:
然后在我的gruntfile中我有以下内容:
我确定这只是语法,但我似乎无法克服这个错误:
Warning: an error occurred while processing a template (Unexpected identifier).
它是“意外标识符”这一事实告诉我,我没有正确地打点“i”或跨越“t”。更有经验的眼睛赞赏!
注意:我考虑过使用grunt-contrib-concat代替,但如果没有 globbing,我将不得不执行 3 个单独的任务来保持独特内容的完整性。
[编辑添加:]
我使用称为(适当地) grunt-includes的不同 grunt 任务在我的非常基本的用例中取得了成功。我能够适当地包含我的文件。
但是,我仍然对grunt-html-build有条件地构建开发或分发包的功能感兴趣。任何见解仍然值得赞赏!
html - Grunt include-replace string unexpexted token 错误/字符串中的特殊字符
当我将字符串添加到grunt-include-replace包括如下所示时,我在控制台中收到“意外令牌错误”,并且 html 文件无法编译。
我认为特殊字符 <>/#" 存在问题。
如何使这些字符在字符串中起作用?
gruntjs - 包括 Gruntfile.js 中提到的 css 文件
从 Gruntfile.js 中读取并包含提到的 css、js 文件。我尝试使用 grunt-include-source 插件但不工作
索引.html
在Gruntfile.js 中
在index.html中
我最终的 index.html 将是
javascript - 使用 grunt 将本地 *.js 和 *.css 文件自动引用到 index.html
我打算开发一个 angularJS 客户端,我将在其中使用 Angular 组件。这将导致多个.js/ .css 文件。为了避免手动引用每个新添加的 js/css 文件,我打算使用 grunt-include-source 任务。
问题是,在配置 Gruntfile.js 之后,“grunt includeSource”任务运行,返回“Done,没有错误”。status 但没有在 index.html 文件中进行更新。
我的项目结构是附图中所示的结构(我使用 WebStorm 作为 IDE)。
我的 index.html 文件如下:
我的 Gruntfile.js 如下:
谁能指出我做错了什么?谢谢你。
html - grunt-include-replace 在编译时添加一个文件夹
我正在努力解决这个问题。我有 include replace 从 src 文件夹中提取并编译到 dist 文件夹中。它正在这样做,但是,它将一个 src 文件夹添加到 dist 文件夹中,并将 html 文件放入其中。如果我从根目录而不是 src 文件夹中提取,它工作得很好,并且只将 html 放入 dist 文件夹,没有额外的文件夹。为什么将路径添加到 src 文件夹中会在 dist 文件夹中创建另一个 src 文件夹,我该如何让它停止这样做?
我的代码是这样设置的......