简体   繁体   English

尝试将所有scss文件编译成一个css文件

[英]Trying to compile all scss files into one css file

I have a grunt file but I am having problems getting it to compile. 我有一个grunt文件,但我在编译时遇到问题。 When I watch it it appears to run fine but does not produce any files. 当我观看它似乎运行正常但不产生任何文件。

What am I missing? 我错过了什么?

module.exports = function(grunt) {
    grunt.initConfig({
        pngmin: {
            compile: {
                options: {
                    ext: '.png',
                    force: true,
                    speed: 3,
                    colors: 200
                },
                files: [{
                    expand: true, // required option
                    src: ['**/*.png'],
                    cwd: 'public/images/src/', // required option
                    dest: 'public/images/dist/'
                }]
            }
        },
        sass: {
            dist: {
                files: [
                    {
                        expand: true,
                        cwd: "public/sass",
                        src: ["**/*.sass"],
                        dest: "public/stylesheets",
                        ext: ".css"
                    }
                ]
            }
        },
        watch: {
            css: {
                files: '**/*.scss',
                tasks: ['sass']
            }
        }
    });


    grunt.loadNpmTasks('grunt-contrib-sass');
    grunt.loadNpmTasks('grunt-contrib-watch');
    grunt.loadNpmTasks('grunt-pngmin');
    grunt.registerTask('default', ['pngmin', 'watch', 'sass']);

};

You are watching scss files, but you have sass files in your sass task. 你正在看scss文件,但你的sass任务中有sass文件。

Assuming you are using sass files, you have to change your code to something like this: 假设您使用的是sass文件,则必须将代码更改为以下内容:

    sass: {
        dist: {
            files: [
                {
                    expand: true,
                    cwd: "public/sass",
                    src: ["**/*.sass"],
                    dest: "public/stylesheets",
                    ext: ".css"
                }
            ]
        }
    },
    watch: {
        css: {
            files: '**/*.sass',
            tasks: ['sass']
        }
    }

Regards. 问候。

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

相关问题 尝试将sass / scss文件编译为css文件(一对一) - Trying to compile sass/scss file into css files (one to one) 在PHP中的一个CSS文件中编译许多SCSS文件 - Compile many SCSS files in one CSS file in PHP 将多个SCSS文件导入一个SCSS文件,编译成一个CSS文件 - Import multiple SCSS files into one SCSS file and compile to one CSS file 将多个 SCSS/SASS 文件转换为一个 CSS 文件? - Many SCSS/SASS files to one CSS file? Webpack 将两个 CSS 文件和一个 SCSS 文件连接成一个 CSS 文件 - Webpack concatenate two CSS files and an SCSS file into one CSS file 在一个脚本中将同一文件夹中的多个 scss 文件编译为多个文件 - Compile multiple scss files in same folder to multiple file in one script 如何获取一堆CSS文件并为所有应用程序制作一个CSS文件 - How can I grab bunch of scss files and make one css file for all application 如何使用Gulp编译将其他.scss导入一个主CSS文件的.scss文件 - How to compile a .scss file that imports other .scss into one master css file using gulp Gulp-sass不会将scss文件编译为css,而是将所有文件从scss文件夹复制到css文件夹 - Gulp-sass won't compile scss files to css instead copy all files from scss folder to css folder 使用 gulp 将所有 scss 文件合并为一个 css 文件 - Combine all scss file to one css file using gulp
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM