如何在Ubuntu 14.04+或Linux Mint 17+上安装node-sass / gulp-sass?

我正在尝试从gulp-ruby-sass切换到node-sass ,它比基于libsass的C实现更快地比经典的Ruby版本更快。

到目前为止,我已经安装了节点包:

节点包

 cd /path/to/project npm install --save-dev node-sass gulp-sass 

Gulpfile

我将要求改为:

 //sass = require('gulp-ruby-sass'), sass = require('gulp-sass'), 

Libsass

然后我去了一个libsass包,但目前没有 。

所以我想知道是否有人将bash脚本构建为当前指令尚不清楚 ?

我将我的研究记录为bash脚本,作为基于官方文档 的要点

编译和安装libsasssassc

安装依赖项

 apt-get install automake libtool 

获取源

 git clone https://github.com/sass/libsass.git git clone https://github.com/sass/sassc.git libsass/sassc 

创建配置脚本

 cd libsass autoreconf --force --install cd .. 

共享库创建自定义makefile

有关更多信息,请参阅: 静态库和共享库之间的区别? 在安装libsass之前。

 cd libsass autoreconf --force --install ./configure \ --disable-tests \ --enable-shared \ --prefix=/usr cd .. 

建立图书馆

 make -C libsass -j5 

安装库

 sudo make -C libsass -j5 install 

测试

只有node-sass

 time node-sass /path/to/main.scss 

成功了

 Rendering Complete, saving .css file... Wrote CSS to /mnt/data/projects/EVRPA/evrpa/web/main.css node-sass ../web/styles/main.scss 0.42s user 0.03s system 95% cpu 0.471 total 

Gulp ruby-sass

 [17:48:21] Using gulpfile /mnt/data/projects/EVRPA/evrpa/web/gulpfile.js [17:48:21] Starting 'css'... [17:48:21] gulp-ruby-sass: directory [17:48:23] gulp-ruby-sass: overwrite main.css [17:48:24] Finished 'css' after 2.9 s gulp css 4.60s user 0.35s system 46% cpu 10.605 total 

Gulp with node-sass

 time gulp css [17:47:59] Using gulpfile /mnt/data/projects/EVRPA/evrpa/web/gulpfile.js [17:47:59] Starting 'css'... [17:48:00] Finished 'css' after 1.1 s gulp css 2.99s user 0.20s system 100% cpu 3.164 total 

结论

我的测试没有基准,没有什么价值,但node-sass似乎比ruby-sass 快3-5倍

以上版本不再适用于当前版本。

我最终得到以下内容:

 git clone https://github.com/sass/libsass.git ~/libsass echo "export SASS_LIBSASS_PATH=~/libsass" >> ~/.bashrc source ~/.bashrc git clone https://github.com/sass/sassc.git ~/sassc cd ~/sassc make echo "export PATH=$PATH:~/sassc/bin/" >> ~/.bashrc source ~/.bashrc sassc -v 

基于https://github.com/sass/sassc/blob/master/docs/building/unix-instructions.md