Grunt:如何将一个scss文件编译为css

时间:2020-06-10 17:06:46

标签: gruntjs

我想用grunt自动编译一个CSS文件。这是我的咕unt声文件。我收到此错误:

运行“ sass:dist”(sass)任务警告:“ path”参数必须为 字符串类型。收到未定义的使用--force继续。

Gruntfile.js

module.exports = function(grunt) {
    grunt.initConfig({
        sass: {                              // Task
          dist: {                            // Target
            options: {                       // Target options
              style: 'compressed'
            },
            files: {
                '‪/static/css/main.css': '‪/static/css/main.scss', // 'destination': 'source'
              //'widgets.css': 'widgets.scss'
            }

          }
        },
        watch: {
            sass:{
                files: ['/‪static/css/*.scss'],
                tasks: ['sass:dist'],
            }
        }
      });

      grunt.loadNpmTasks('grunt-contrib-sass');
      grunt.loadNpmTasks('grunt-contrib-watch');

      grunt.registerTask('default', ['sass:dist']);

  };

我的json包是这样的,我在我的机器上安装了ruby:

package.json

{
  "name": "grunt-crm1",
  "version": "1.0.0",
  "author": "Gregor",
  "devDependencies": {
    "grunt": "^1.0.1",
    "grunt-contrib-watch": "^1.1.0",
    "grunt-contrib-sass": "^1.0.0"
  },
  "dependencies": {}
}

0 个答案:

没有答案