【发布时间】:2014-07-13 21:03:03
【问题描述】:
当我运行time sassc app.scss app.css时,编译时间非常快:
sassc 是 libsass 库上 C 实现的命令行包装器。
real __0m0.132s__
user 0m0.123s
sys 0m0.007s
但是,当使用 grunt-sass 时,Node.js 是 libsass 的包装器,
在我的Gruntfile.js 中,输出速度要慢得多:
Running "watch" task
Waiting...
File "stylesheets/sass/app.scss" changed.
Running "sass:compile" (sass) task
File ./stylesheets/app.css created.
Done, without errors.
Completed in __1.759s__ at Sat May 24 2014 18:17:33 GMT+0200 (CEST) - Waiting...
这是我Gruntfile.js的相关部分,也许我在这里做错了什么:
module.exports = function(grunt) {
grunt.initConfig({
project: {
app: '.',
sheets: '<%= project.app %>/stylesheets',
sass: [ '<%= project.sheets %>/sass/app.scss',
],
js: [],
},
// The watch task is used to run tasks in response to file changes
watch: {
options: {
livereload: true,
},
html: {
files: ['<%= project.app %>/*.html'],
},
css: {
files: ['<%= project.sheets %>/*.css'],
},
sass: {
files: '<%= project.sheets %>/sass/{,*/}*.{scss,sass}',
tasks: ['sass:compile'],
options: {
livereload: false,
},
},
},
sass: {
compile: {
options: {
style: 'nested',
},
files: {
'<%= project.sheets %>/app.css' : '<%= project.sheets %>/sass/app.scss',
}
}
},
}); // The end of grunt.initConfig
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-sass');
grunt.registerTask('preview', ['watch', ]);
};
为什么在 Grunt 中我的编译时间如此缓慢?
【问题讨论】:
-
你有没有弄明白这件事?我也有类似的问题
-
深入了解我的问题。那是因为我是通过网络存钱的……呃!
-
@branquito 你有没有解决你的问题?
-
@TheFrost 不,我没有。我所做的是,我将
entr[entrproject.org/] 用于按需编译与sassc结合使用,这可以提高编译速度,然后在需要时将grunt用于其他任务。