LoginSignup
1
1

More than 5 years have passed since last update.

Jekyll で es2015 ( babel ) を使う

Posted at

日本語でそのものズバリの記事がなかったのですが、 jekyll-babel というプラグインを利用して簡単に babel だけを導入できます。使っている jekyll のバージョンは 3.1.1 。
asset-pipeline をセットアップするのはめんどいけど、 var とか書きたくないよって時にどうぞ。

Gemfile
gem 'jekyll-babel'
_config.yml
gems:
  - jekyll-babel
script.es6
---
---
// ^^^ those two lines are required by Jekyll

const es6 = "ready!";
let it = "be";
  1. gemfile に gem 'jekyll-babel'を追加
  2. bundle init を実行
  3. _config.yml の gems:- jekyll-babel を追加
  4. js フォルダ内に *.es6 と拡張子を設定して保存
  5. 対象のファイルの先頭に ---(改行)--- を記載
  6. jekyll build --watch を実行。 _site/js 内に *.js と変換されて出力されます

5番がちょっとキモイですが、 jekyll に変換対象のファイルだとわからせるために必要な模様。
多分、事前に node.jsbabel-cli 、 babel-es2015-preset が必要です。

npm install -g babel-cli
npm install -g babel-preset-es2015

参考

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1