精华 #dailynodejs# 最新最快最亲身的node分享
发布于 10 年前 作者 yaochun 4097 次浏览 最后一次编辑是 8 年前 来自 分享

给社区的小伙伴也分享一下一个不错的工具包:

欢迎关注我们的微博:dailyNodejs

我们是几个生活在node第一线的【老前端人】,热衷分享一些最直接的node内容,坚持daily,欢迎有node相关的内容@我们一下哦

#Takana#

Takana lets you see your SCSS and CSS style changes live, in the browser, as you type them.

亲身装了一下,有一些体会:

===========

看了一下,确实有一个grunt的插件 :

https://github.com/mechio/grunt-takana/

这个代码很简单,就是

pkg里面:

"dependencies": {
    "takana": "0.0.8"
  },

然后tasks文件里面直接调用这个包:

takana.run({
      path:         fs.realpathSync(options.path),
      includePaths: options.includePaths
    });

--------------------------------- 分割线 ------------------------------------

但是takana这个包就比较复杂:

1、pkg依赖:

"dependencies": {
    "underscore": "~1.5.2",
    "nssocket": "~0.5.1",
    "log4js": "~0.6.9",
    "node-sass": "^0.9.5-rc1",
    "connect": "~2.12.0",
    "shelljs": "~0.2.6",
    "q": "~1.0.0",
    "websocket": "~1.0.8",
    "express": "~3.4.8",
    "coffee-script": "~1.6.3",
    "commander": "~2.1.0",
    "takana-client": "^1.0.3",
    "chokidar": "^0.9.0",
    "mime": "^1.2.11"
  },

2、源码满眼都是coffee编写:

3、用一个takana.py来安装Sublime插件,支持2和3版本

也映衬了官网的原话: Then open one of its referenced stylesheets in Sublime and start live-editing!

var takanaPackagePath = null,
      searchPaths = [
    helpers.sanitizePath('~/Library/Application Support/Sublime Text 3/Packages/'),
    helpers.sanitizePath('~/Library/Application Support/Sublime Text 2/Packages/'),
    helpers.sanitizePath('~/.config/sublime-text-3/Packages/') // linux
  ];

后面用shelljs 来安装插件 (其实就是拷贝自己目录下的takana,py)到Sublime Text 3/Packages/ 或者 Sublime Text 2/Packages/ 下面

//Creates directories.
shell.mkdir('-p', takanaPackagePath);
//Copies files
shell.cp('-f', path.join(__dirname, './sublime-plugin/takana.py'), path.join(takanaPackagePath, 'takana.py'));

4、自己内置一个服务:

https://github.com/mechio/takana/blob/master/lib/server.coffee

内容比较多,满眼coffee,有兴趣可以看看

5、配置:

  • skipSublime – 是否需要安装sublime插件
if (!options.skipSublime){
installSublimePlugin();
}
  • verbose – 内部调用log4js来打日志
  • path - 必须的
  • includePaths
3 回复

排版高亮下?

如果目前在自动化工具里面已经使用grunt-contrib-compass来处理sass这种编译的,想要迁移到Takana的化,注意:

Takana uses libsass under the hood, if you’re using node-sass you’ll be fine. However, if you’re using the ruby compiler, you may need to refactor your code to get it running with libsass.

回到顶部