简体   繁体   English

Jekyll +聚合物+硫化-这是如何工作的?

[英]Jekyll + Polymer + Vulcanize - How does this work?

I just started integrating Polymer into my Jekyll environment. 我刚刚开始将Polymer集成到我的Jekyll环境中。 Essentially, I created a bower.json file in my Jekyll root that calls for followingdepencendies: 本质上,我在Jekyll根目录中创建了bower.json文件,该文件要求以下依赖:

...
],
 "dependencies": {
"iron-elements": "PolymerElements/iron-elements#^1.0.0",
"paper-elements": "PolymerElements/paper-elements#^1.0.1",
"polymer": "Polymer/polymer#^1.2.0"
  }
}

After running bower install in my Jekyll root, I ge the bower_components folder with all Polymer packages I requested. 在我的Jekyll根目录中运行bower install之后,将包含我请求的所有Polymer软件包的bower_components文件夹放入ge。 In my Jekyll template's head.html , I include 在我的Jekyll模板的head.html ,包括

<link rel="import" href="{{ site.baseurl }}/bower_components/paper-item/paper-item.html">
<link rel="import" href="{{ site.baseurl }}/bower_components/paper-tabs/paper-tabs.html">
<link rel="import" href="{{ site.baseurl }}/bower_components/paper-toolbar/paper-toolbar.html">
<link rel="import" href="{{ site.baseurl }}/bower_components/iron-icons/iron-icons.html">
<link rel="import" href="{{ site.baseurl }}/bower_components/paper-icon-button/paper-icon-button.html">
<link rel="import" href="{{ site.baseurl }}/bower_components/iron-flex-layout/iron-flex-layout.html">
 ...

in order to integrate the desired Polymer packages. 为了集成所需的聚合物包装。 I run jekyll serve to create and see the page. 我运行jekyll serve创建并查看页面。 So far so good. 到现在为止还挺好。

However, I feel this may produce a long loading time for my page, not? 但是,我认为这可能会导致页面加载时间较长,不是吗? I'm, almost sure Google's own website speed test would ask me to reduce the number of http calls. 我几乎可以肯定,谷歌自己的网站速度测试会要求我减少http呼叫的次数。 As I discovered, Polymer provides a package named vulcanize to combine the http requests into one: https://github.com/polymer/vulcanize 正如我发现的,Polymer提供了一个名为vulcanize的软件包,可将http请求合并为一个: https : //github.com/polymer/vulcanize

Honestly, I have no clear idea how to integrate this into my process. 老实说,我不清楚如何将其集成到我的流程中。 I've seen some docs that talk about grunt but honestly I have no idea about that. 我看过一些有关grunt文档,但老实说,我对此一无所知。

Can anyone provide a small input on how to compress my Polymer featured Jekyll page (html, html calls, css...) ? 谁能提供一些关于如何压缩我的Polymer特色Jekyll页面 (html,html调用,css ...)的信息 Thanks! 谢谢!

I had this same issue and finally got around to a solution, in case you're still working on this. 我也遇到了同样的问题,终于找到了解决方案,以防万一您还在努力。 (Originally posted here ) (最初在此处发布)

I used Gulp, copying the Polymer Starter Kit (1.2.3). 我使用Gulp,复制了Polymer Starter Kit (1.2.3)。 I used the package.json , tasks/ directory, and modified gulpfile.js. 我使用了package.jsontasks/目录和修改后的gulpfile.js. I changed the behavior of the default and serve tasks to run Jekyll serve and build in the shell. 我更改了defaultserve任务的行为,以运行Jekyll服务并在shell中进行构建。 I also changed directory references in the gulpfile to vulcanize the files in app/_site/ instead of app/ . 我还更改了gulpfile中的目录引用,以硫化app/_site/的文件,而不是app/

var spawn = require('child_process').spawn;
var argv = require('yargs').argv;

gulp.task('jekyllbuild', function(done) {
  return spawn('bundle', ['exec', 'jekyll', 'build'], { stdio: 'inherit' })
      .on('close', done);
});

// Build production files, the default task
gulp.task('default', ['clean'], function(cb) {
  // Uncomment 'cache-config' if you are going to use service workers.
  runSequence(
    'jekyllbuild',
    ['ensureFiles', 'copy', 'styles'],
    'elements',
    ['images', 'fonts', 'html'],
    'vulcanize', // 'cache-config',
    cb);
});

gulp.task('serve', function(done) {
  if (argv.port) {
    return spawn('bundle', ['exec', 'jekyll', 'serve', '--port=' + argv.port], { stdio: 'inherit' })
        .on('close', done);
  } else {
    return spawn('bundle', ['exec', 'jekyll', 'serve'], { stdio: 'inherit' })
        .on('close', done);
  }
});

Using BrowserSync would have a much cleaner effect, but this is a simple way to get Jekyll functionality and the benefit of vulcanization for production. 使用BrowserSync将产生更清洁的效果,但这是获得Jekyll功能和硫化生产优势的简单方法。 (Note that you also have to install the yargs package to handle port specification.) My whole gulpfile is here . (请注意,您还必须安装yargs软件包以处理端口规范。)我的整个gulpfile在这里

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM