简体   繁体   English

尝试将sass / scss文件编译为css文件(一对一)

[英]Trying to compile sass/scss file into css files (one to one)

We are trying to compile our sass files to css files, however we want to compile each individual sass file into an individual css file (one-to-one). 我们正在尝试将sass文件编译为css文件,但是我们希望将每个单独的sass文件编译为一个单独的css文件(一对一)。

For example our product_view.scss should have a product_view.css . 例如,我们的product_view.scss应该具有product_view.css

However all configurations we have tried create one css file for everything called styles.css in our "out/css" folder. 但是,我们尝试过的所有配置都为“ out / css”文件夹中的所有名为styles.css的文件创建了一个CSS文件。

sass: {
    dist: {
        options: {
            compass: true,
            style: 'expanded'
        },
        files: [{
            expand: true,
            cwd: '<%= pkg.src %>/assets/sass',
            src: ['*.scss'],
            dest: '<%= pkg.src %>/assets/media/out/css',
            ext: '.css'
        }]
    },

},

I use grunt-contrib-compass (Compass) to compile my SASS, which has some nice extras. 我使用grunt-contrib-compass (Compass)来编译我的SASS,它具有一些不错的功能。 For example, compass includes a reset utility you can use by using 例如,指南针包含一个重置实用程序,您可以通过使用

@import 'compass/reset';

But disregarding that, compass also outputs every file individually (as long as it does not start with _ which are files that can be included but won't be compiled by themselves). 但不管怎么说,指南针还会单独输出每个文件(只要它不以_开头,这些文件可以包含但不会自己编译)。 Here is the setup I use in my gruntfile: 这是我在gruntfile中使用的设置:

compass: {
    'default': {
        options: {
            sassDir: "css/sass/",
            cssDir: "css/",
            outputStyle: "compressed"
        }
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM