Sass 将yeoman生成的Gruntfile.js文件更改为将.css文件与.scss文件分开

Sass 将yeoman生成的Gruntfile.js文件更改为将.css文件与.scss文件分开,sass,compass-sass,gruntjs,yeoman,livereload,Sass,Compass Sass,Gruntjs,Yeoman,Livereload,我试图稍微修改由Yeoman(1.0)生成的默认webapp Gruntfile.js。默认设置在“样式”下同时设置.css和.scss文件,但不在子目录下拾取子目录.scss部分,这意味着它们不会呈现为.css 我一直在试图修改它,以便我的.scss文件位于“/styles/scss/”目录下,而我生成的.css文件位于“/styles/css/”目录下 我已经设法将子目录中的.scss文件渲染为.css,但现在livereload在部分内容更改时不会更新,尽管在进行更改时,我可以看到“监视”

我试图稍微修改由Yeoman(1.0)生成的默认webapp Gruntfile.js。默认设置在“样式”下同时设置.css和.scss文件,但不在子目录下拾取子目录.scss部分,这意味着它们不会呈现为.css

我一直在试图修改它,以便我的.scss文件位于“/styles/scss/”目录下,而我生成的.css文件位于“/styles/css/”目录下

我已经设法将子目录中的.scss文件渲染为.css,但现在livereload在部分内容更改时不会更新,尽管在进行更改时,我可以看到“监视”任务将我的.scss渲染为.css

关于如何让livereload在.scss文件更改时自动呈现.css,您有什么想法吗

感谢您的帮助

当前修订的Grunt.js文件:

// Generated on 2013-06-21 using generator-webapp 0.2.4
'use strict';
var LIVERELOAD_PORT = 35729;
var lrSnippet = require('connect-livereload')({port: LIVERELOAD_PORT});
var mountFolder = function (connect, dir) {
    return connect.static(require('path').resolve(dir));
};

// # Globbing
// for performance reasons we're only matching one level down:
// 'test/spec/{,*/}*.js'
// use this if you want to recursively match all subfolders:
// 'test/spec/**/*.js'

module.exports = function (grunt) {
    // load all grunt tasks
    require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);

    // configurable paths
    var yeomanConfig = {
        app: 'app',
        dist: 'dist'
    };

    grunt.initConfig({
        yeoman: yeomanConfig,
        watch: {
            options: {
                nospawn: true
            },
            coffee: {
                files: ['<%= yeoman.app %>/scripts/{,*/}*.coffee'],
                tasks: ['coffee:dist']
            },
            coffeeTest: {
                files: ['test/spec/{,*/}*.coffee'],
                tasks: ['coffee:test']
            },
            compass: {
                files: ['<%= yeoman.app %>/styles/**/*.{scss,sass}'],
                tasks: ['compass:server']
            },
            livereload: {
                options: {
                    livereload: LIVERELOAD_PORT
                },
                files: [
                    '<%= yeoman.app %>/*.html',
                    '{.tmp,<%= yeoman.app %>}/styles/css/*.css',
                    '{.tmp,<%= yeoman.app %>}/scripts/{,*/}*.js',
                    '<%= yeoman.app %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}'
                ]
            }
        },
        connect: {
            options: {
                port: 9000,
                // change this to '0.0.0.0' to access the server from outside
                hostname: 'localhost'
            },
            livereload: {
                options: {
                    middleware: function (connect) {
                        return [
                            lrSnippet,
                            mountFolder(connect, '.tmp'),
                            mountFolder(connect, yeomanConfig.app)
                        ];
                    }
                }
            },
            test: {
                options: {
                    middleware: function (connect) {
                        return [
                            mountFolder(connect, '.tmp'),
                            mountFolder(connect, 'test')
                        ];
                    }
                }
            },
            dist: {
                options: {
                    middleware: function (connect) {
                        return [
                            mountFolder(connect, yeomanConfig.dist)
                        ];
                    }
                }
            }
        },
        open: {
            server: {
                path: 'http://localhost:<%= connect.options.port %>'
            }
        },
        clean: {
            dist: {
                files: [{
                    dot: true,
                    src: [
                        '.tmp',
                        '<%= yeoman.dist %>/*',
                        '!<%= yeoman.dist %>/.git*'
                    ]
                }]
            },
            server: '.tmp'
        },
        jshint: {
            options: {
                jshintrc: '.jshintrc'
            },
            all: [
                'Gruntfile.js',
                '<%= yeoman.app %>/scripts/{,*/}*.js',
                '!<%= yeoman.app %>/scripts/vendor/*',
                'test/spec/{,*/}*.js'
            ]
        },
        mocha: {
            all: {
                options: {
                    run: true,
                    urls: ['http://localhost:<%= connect.options.port %>/index.html']
                }
            }
        },
        coffee: {
            dist: {
                files: [{
                    expand: true,
                    cwd: '<%= yeoman.app %>/scripts',
                    src: '{,*/}*.coffee',
                    dest: '.tmp/scripts',
                    ext: '.js'
                }]
            },
            test: {
                files: [{
                    expand: true,
                    cwd: 'test/spec',
                    src: '{,*/}*.coffee',
                    dest: '.tmp/spec',
                    ext: '.js'
                }]
            }
        },
        compass: {
            options: { 
                sassDir: '<%= yeoman.app %>/styles/scss',
                cssDir: '.tmp/styles/css',
                generatedImagesDir: '.tmp/images/generated',
                imagesDir: '<%= yeoman.app %>/images',
                javascriptsDir: '<%= yeoman.app %>/scripts',
                fontsDir: '<%= yeoman.app %>/styles/fonts',
                importPath: '<%= yeoman.app %>/bower_components',
                httpImagesPath: '/images',
                httpGeneratedImagesPath: '/images/generated',
                httpFontsPath: '/styles/fonts',
                relativeAssets: false
            },
            dist: {},
            server: {
                options: {
                    debugInfo: true
                }
            }
        },
        // not used since Uglify task does concat,
        // but still available if needed
        /*concat: {
            dist: {}
        },*/
        // not enabled since usemin task does concat and uglify
        // check index.html to edit your build targets
        // enable this task if you prefer defining your build targets here
        /*uglify: {
            dist: {}
        },*/
        rev: {
            dist: {
                files: {
                    src: [
                        '<%= yeoman.dist %>/scripts/{,*/}*.js',
                        '<%= yeoman.dist %>/styles/css/*.css',
                        '<%= yeoman.dist %>/images/{,*/}*.{png,jpg,jpeg,gif,webp}',
                        '<%= yeoman.dist %>/styles/fonts/*'
                    ]
                }
            }
        },
        useminPrepare: {
            options: {
                dest: '<%= yeoman.dist %>'
            },
            html: '<%= yeoman.app %>/index.html'
        },
        usemin: {
            options: {
                dirs: ['<%= yeoman.dist %>']
            },
            html: ['<%= yeoman.dist %>/{,*/}*.html'],
            css: ['<%= yeoman.dist %>/styles/css/*.css']
        },
        imagemin: {
            dist: {
                files: [{
                    expand: true,
                    cwd: '<%= yeoman.app %>/images',
                    src: '{,*/}*.{png,jpg,jpeg}',
                    dest: '<%= yeoman.dist %>/images'
                }]
            }
        },
        svgmin: {
            dist: {
                files: [{
                    expand: true,
                    cwd: '<%= yeoman.app %>/images',
                    src: '{,*/}*.svg',
                    dest: '<%= yeoman.dist %>/images'
                }]
            }
        },
        cssmin: {
            dist: {
                files: {
                    '<%= yeoman.dist %>/styles/css/main.css': [
                        '.tmp/styles/css/*.css',
                        '<%= yeoman.app %>/styles/css/*.css'
                    ]
                }
            }
        },
        htmlmin: {
            dist: {
                options: {
                    /*removeCommentsFromCDATA: true,
                    // https://github.com/yeoman/grunt-usemin/issues/44
                    //collapseWhitespace: true,
                    collapseBooleanAttributes: true,
                    removeAttributeQuotes: true,
                    removeRedundantAttributes: true,
                    useShortDoctype: true,
                    removeEmptyAttributes: true,
                    removeOptionalTags: true*/
                },
                files: [{
                    expand: true,
                    cwd: '<%= yeoman.app %>',
                    src: '*.html',
                    dest: '<%= yeoman.dist %>'
                }]
            }
        },
        // Put files not handled in other tasks here
        copy: {
            dist: {
                files: [{
                    expand: true,
                    dot: true,
                    cwd: '<%= yeoman.app %>',
                    dest: '<%= yeoman.dist %>',
                    src: [
                        '*.{ico,png,txt}',
                        '.htaccess',
                        'images/{,*/}*.{webp,gif}',
                        'styles/fonts/*'
                    ]
                }, {
                    expand: true,
                    cwd: '.tmp/images',
                    dest: '<%= yeoman.dist %>/images',
                    src: [
                        'generated/*'
                    ]
                }]
            }
        },
        concurrent: {
            server: [
                'compass',
                'coffee:dist'
            ],
            test: [
                'coffee'
            ],
            dist: [
                'coffee',
                'compass',
                'imagemin',
                'svgmin',
                'htmlmin'
            ]
        }
    });

    grunt.registerTask('server', function (target) {
        if (target === 'dist') {
            return grunt.task.run(['build', 'open', 'connect:dist:keepalive']);
        }

        grunt.task.run([
            'clean:server',
            'concurrent:server',
            'connect:livereload',
            'open',
            'watch'
        ]);
    });

    grunt.registerTask('test', [
        'clean:server',
        'concurrent:test',
        'connect:test',
        'mocha'
    ]);

    grunt.registerTask('build', [
        'clean:dist',
        'useminPrepare',
        'concurrent:dist',
        'cssmin',
        'concat',
        'uglify',
        'copy:dist',
        'rev',
        'usemin'
    ]);

    grunt.registerTask('default', [
        'jshint',
        'test',
        'build'
    ]);
};
//使用generator webapp 0.2.4于2013年6月21日生成
"严格使用",;
var LIVERELOAD_PORT=35729;
var lrnippet=require('connect-livereload')({port:livereload_port});
var mountFolder=函数(连接,目录){
返回connect.static(require('path').resolve(dir));
};
//#全球化
//出于性能原因,我们只降低了一个级别:
//'test/spec/{,*/}*.js'
//如果要递归匹配所有子文件夹,请使用此选项:
//“test/spec/***.js”
module.exports=函数(grunt){
//加载所有grunt任务
require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);
//可配置路径
var yeomanConfig={
应用程序:“应用程序”,
dist:“dist”
};
grunt.initConfig({
约曼:约曼图,
观察:{
选项:{
nospawn:是的
},
咖啡:{
文件:['/scripts/{,*/}*.coffee'],
任务:['coffee:dist']
},
咖啡测试:{
文件:['test/spec/{,*/}*.coffee'],
任务:[“咖啡:测试”]
},
指南针:{
文件:['/styles/***.{scss,sass}'],
任务:['compass:server']
},
利弗雷罗德:{
选项:{
利弗雷洛德:利弗雷洛德港口
},
档案:[
“/*.html”,
“{.tmp,}/styles/css/*.css”,
“{.tmp,}/scripts/{,*/}*.js”,
“/images/{,*/}*{png,jpg,jpeg,gif,webp,svg}”
]
}
},
连接:{
选项:{
港口:9000,
//将此更改为“0.0.0.0”以从外部访问服务器
主机名:“localhost”
},
利弗雷罗德:{
选项:{
中间件:功能(连接){
返回[
小片段,
mountFolder(连接“.tmp”),
mountFolder(连接,yeomanConfig.app)
];
}
}
},
测试:{
选项:{
中间件:功能(连接){
返回[
mountFolder(连接“.tmp”),
安装文件夹(连接“测试”)
];
}
}
},
地区:{
选项:{
中间件:功能(连接){
返回[
mountFolder(连接,yeomanConfig.dist)
];
}
}
}
},
开放式:{
服务器:{
路径:'http://localhost:'
}
},
清洁:{
地区:{
档案:[{
多特:没错,
src:[
“.tmp”,
'/*',
“!/.git*”
]
}]
},
服务器:'.tmp'
},
jshint:{
选项:{
jshintrc:“.jshintrc”
},
全部:[
“Gruntfile.js”,
“/scripts/{,*/}*.js”,
“!/scripts/vendor/*”,
'test/spec/{,*/}*.js'
]
},
摩卡咖啡:{
全部:{
选项:{
run:是的,
网址:['http://localhost:/index.html']
}
}
},
咖啡:{
地区:{
档案:[{
是的,
cwd:“/scripts”,
src:“{,*/}*.coffee”,
目标:'.tmp/scripts',
分机:'.js'
}]
},
测试:{
档案:[{
是的,
cwd:“测试/规范”,
src:“{,*/}*.coffee”,
目的地:'.tmp/spec',
分机:'.js'
}]
}
},
指南针:{
选项:{
sassDir:“/styles/scss”,
cssDir:“.tmp/styles/css”,
generatedImagesDir:'.tmp/images/generated',
imagesDir:“/images”,
javascriptsDir:“/scripts”,
fontsDir:“/styles/fonts”,
导入路径:'/bower_components',
httpImagesPath:“/images”,
httpGeneratedImagesPath:“/images/generated”,
httpFontsPath:“/styles/fonts”,
相对论集:假
},
地区:{},
服务器:{
选项:{
debugInfo:true
}
}
},
//未使用,因为丑陋的任务不起作用,
//但仍然可用