0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Sublime2でhamlとbabelる

Last updated at Posted at 2016-04-11

パス周りでやたらと苦労したので備忘録。

絶対パスで行く

rbenvとか使ってると、いろいろと苦労したので。。

##rbenv + haml
事前にrbenvのglobalにhamlをインストールしておく

json|Haml.sublime-build
{
  "cmd": "haml",
  "selector": "text.haml",
  "working_dir": "${file_path}",
        
  "osx":
  {
    "cmd": ["/users/hiraotakenori/.rbenv/shims/haml","-E", "UTF-8", "$file", "$file_path/$file_base_name.html"]
  }
}

##rbenv + sass
事前にrbenvのglobalにsassをインストールしておく
sublime2がsassをsassと認識する必要があるので、Sassパッケージなどを入れて、sassを認識させておく。

json|Saas.sublime-build
{
  "cmd": "sass",
  "selector": "source.sass",

  "osx":
  {
	  "cmd": ["/users/hiraotakenori/.rbenv/shims/sass", "$file:${file_path}/${file_base_name}.css"]
  }
}

##babel
事前にbabelを入れてes2015でコンパイルできるように設定しておく

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

json|.babelrc
{
  "presets": ["es2015"]
}

sublime2さんがbabelもnodeも認識してくれないので、絶対パスで。
sublime2にes6系のパッケージを入れて、es6=javascriptと覚えさせておく。

json|Haml.sublime-build
{
  "cmd": "node",
  "selector": "source.js",
  "working_dir": "${file_path}",
        
  "osx":
  {
    "cmd": ["/usr/local/bin/node", "/usr/local/lib/node_modules/babel-cli/bin/babel", "$file", "--out-file", "$file_path/$file_base_name.js"]
  }
}

##SublimeOnSaveBuild
自動的にソースをビルドしてくれる素敵プラグイン。
jsをコンパイルされると変になりそうなので、外しておく。

json|SublimeOnSaveBuild.sublime-settings
{
    "filename_filter": "\\.(es6|sass|less|scss|haml|coffee)$",
    "build_on_save": 1
}
0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?