- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我有一个基于 Jekyll 的网站,我想尽快完成它。我的目标是构建 Jekyll 站点、生成关键 CSS 并缩小 HTML 的 gulp 任务。
我的 gulpfile 的一部分看起来像这样:
gulp.task("jekyll", function (gulpCallBack){
var spawn = require("child_process").spawn;
var jekyll = spawn('jekyll', ["build"], {stdio: "inherit"});
jekyll.on("exit", function(code) {
gulpCallBack(code === 0 ? null : "ERROR: Jekyll process exited with code: "+code);
});
});
gulp.task("html", function() {
gulp.src("./_site/index.html")
.pipe(htmlmin({collapseWhitespace: true}))
.pipe(gulp.dest("./_site"))
gulp.src("./_site/*/*.html")
.pipe(htmlmin({collapseWhitespace: true}))
.pipe(gulp.dest("./_site/./"))
});
gulp.task("critical", function() {
critical.generate({
base: '_site/',
src: 'index.html',
dest: 'css/critical.css',
minify: true,
extract: true,
width: 320,
height: 480
});
critical.inline({
base: '_site/',
src: 'index.html',
dest: 'index.html',
minify: true
});
})
如果我分别运行任务,gulp jekyll
,然后是 gulp html
,最后是 gulp critical
,一切正常,如我所愿。由于我很懒,我不想每次都手动运行三个任务。我的想法是使用以下代码同步/一个接一个地运行它们。
gulp.task("jekyll", function (gulpCallBack){};
gulp.task("html", ["jekyll"], function() {};
gulp.task("critical", ["html"], function() {};
我想,我可以运行 gulp critical
等待 html 任务完成,等待 jekyll 任务完成。该网站已构建并缩小,但未注入(inject)关键 CSS。任务以正确的顺序运行。
➜ jonas.re git:(master) ✗ gulp critical
[19:21:18] Using gulpfile ~/dev/jonas.re/gulpfile.js
[19:21:18] Starting 'jekyll'...
Configuration file: /Users/j.reitmann/dev/jonas.re/_config.yml
Source: /Users/j.reitmann/dev/jonas.re
Destination: /Users/j.reitmann/dev/jonas.re/_site
Generating...
done.
Auto-regeneration: disabled. Use --watch to enable.
[19:21:18] Finished 'jekyll' after 528 ms
[19:21:18] Starting 'html'...
[19:21:18] Finished 'html' after 5.37 ms
[19:21:18] Starting 'critical'...
[19:21:18] Finished 'critical' after 1.63 ms
同样,通过依次手动运行它们,效果非常好。
我听说过runSequence但我必须返回一个流,我不知道要为 jekyll 任务执行此操作(如果可能的话?)。也许错误有所不同,因为这有效:
➜ jonas.re git:(master) ✗ gulp jekyll
[19:27:49] Using gulpfile ~/dev/jonas.re/gulpfile.js
[19:27:49] Starting 'jekyll'...
Configuration file: /Users/j.reitmann/dev/jonas.re/_config.yml
Source: /Users/j.reitmann/dev/jonas.re
Destination: /Users/j.reitmann/dev/jonas.re/_site
Generating...
done.
Auto-regeneration: disabled. Use --watch to enable.
[19:27:50] Finished 'jekyll' after 549 ms
➜ jonas.re git:(master) ✗ gulp html
[19:27:54] Using gulpfile ~/dev/jonas.re/gulpfile.js
[19:27:54] Starting 'html'...
[19:27:54] Finished 'html' after 5.56 ms
➜ jonas.re git:(master) ✗ gulp critical
[19:27:57] Using gulpfile ~/dev/jonas.re/gulpfile.js
[19:27:57] Starting 'critical'...
[19:27:57] Finished 'critical' after 1.66 ms
如有任何帮助,我将不胜感激。你可以看看我的整个 gulpfile here .
最佳答案
问题来自关键。我让它像这样工作:
因为我们需要解析 style.scss
以便生成关键的 css。从 exclude
数组中移除 /css/style.scss
。
./_sass
路径是无用的,它是 Jekyll sass 处理器的默认路径。为了进行处理,此文件需要一个空的前端内容。
---
---
@import "_assets/fonts.scss";
@import "_assets/mixins.scss";
@import "_assets/reset.scss";
@import "_assets/colors.scss";
@import "_assets/syntax-highlighter.scss";
@import "_modules/header.scss";
@import "_modules/content.scss";
关键需要原始样式表的链接。去掉css加载脚本,替换成
<link rel="stylesheet" href="{{ "/css/style.css" | prepend: site.baseurl }}">
加载脚本会被critical插入。
您现在可以链接您的任务。请注意,我已将关键方法更改为 generateInline。
gulp.task("jekyll", function (gulpCallBack){
...
gulp.task("html", ["jekyll"], function() {
...
gulp.task("critical", ["html"], function() {
critical.generateInline({
base: '_site/',
src: 'index.html',
dest: 'css/critical.css',
htmlTarget: 'index.html',
minify: true,
extract: true,
width: 320,
height: 480
});
})
叮!
关于html - Jekyll、关键 CSS、HTML 压缩在一个任务中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29039499/
我已经运行 nagios 大约两年了,但最近这个问题开始出现在我的一项服务中。 我越来越 CRITICAL - Socket timeout after 10 seconds 对于 check_htt
我用 CSS 做到了这一点: 但我希望我的客户更改图像框架。在我的图像中,当前帧只是一种颜色 (#000)。但框架可以是装饰性的。因此,客户应使用装饰图像进行取景。我看过 W3Schools' bor
我编写了一个脚本来检查对象中是否有任何缺失的字段,然后返回具有缺失字段的项目的 ID。 它正在返回: [ '222', '333' ] 我期望返回: ['333'] 为什么它也返回222 id? fu
我正在读 Ramakrishnan 的书数据库管理系统,在模式细化和范式相关的章节中,我看到一句话说: K is a candidate key for R means that K ----> R
我正在编写一个 Java 应用程序,以在一夜之间自动化在线游戏中的角色 Action (特别是,它在《最终幻想 XI》中捕鱼)。该应用程序大量使用 java 的 Robot 类来模拟用户键盘输入和检测
我有这个 react 代码,我在某些输入组件上使用 new Date().getTime() 作为 react 键 Prop 。这可能是一种反模式,因为键需要稳定。但我想了解为什么这如此有问题。为什么
我正在尝试将我的简单查询优化为更复杂的查询。 我有三个表 Table 1 a_id info 1 talk 2 talk 3 sleep 4 sit Table 2
Google PageSpeed 审核建议将首屏内容的关键 CSS 添加到 中的标签,并将其余部分推迟到内容加载完成之后。 虽然我不同意这种做法,但正确的实现方式是什么? 我对使用它有一些保留意见
我已经使用 Pika 将 Websocket 集成到 Tornado 和 RabbitMQ 中。它成功地在各种队列上运行直到一段时间。然后引发以下错误: 严重:pika.connection:关闭时尝
我在本地使用 Gulp 和 SASS 进行开发,为动态站点(即 CMS 驱动)编译 CSS。我正在尝试配置一个解决方案来编译全局与关键路径 CSS。到目前为止最好的想法是将我的主要 scss 文件拆分
关于为 gtkmm 运行以下 simple.cc 示例 #include int main(int argc, char * argv[]){ Glib::RefPtr app = Gt
我正在生成一个 TSX 元素列表: this.productsModel = this.state.products.map(o => ( 但是,react 警告我:
我正在使用 Addy Osmani 的“Critical” https://github.com/addyosmani/critical 下面的 package.json 工作正常,但构建仅复制关键
我有一个 Multimap multimap = ArrayListMultimap.create(); 来自 Guava 。我想知道如何对多图中的 Date 键进行排序。 目前,我正在这样做:
我有一个基于 Jekyll 的网站,我想尽快完成它。我的目标是构建 Jekyll 站点、生成关键 CSS 并缩小 HTML 的 gulp 任务。 我的 gulpfile 的一部分看起来像这样: gul
考虑以下串行函数。当我并行化我的代码时,每个线程都会从并行区域(未显示)内调用此函数。我正在努力使这个线程安全和高效(快速)。 float get_stored_value__or__calculat
我正尝试在 tensorflow 中为我自己的自定义类别重新训练 Inception v3 模型。我已经下载了一些数据并将其格式化为目录。当我运行时,python 脚本为图像创建了瓶颈,然后当它运行时
我该如何追查此错误消息的根本原因? (test:1090): GStreamer-CRITICAL **: gst_debug_log_valist: assertion `category != N
我想为要托管在 Pivotal CloudFoundry 上的 Spring Boot 应用程序强制执行 HTTPS,我想现在大多数应用程序都需要这样做。据我所知,常用的方法是使用 http.requ
在 Travis CI 上运行 Pytest 时,我收到 Key -Error。请在下面找到我的程序: import sys import os sys.path.append(os.path.dir
我是一名优秀的程序员,十分优秀!