Grunt和Less。没有找到“更少”的目标?

时间:2015-07-28 13:01:04

标签: javascript angularjs gruntjs yeoman

我使用Yeoman安装了angular-generator我未来的项目,我计划使用less

我有什么:

npm install grunt-contrib-less --save-dev

Gruntfile.js

watch: {
            tests: '<%= nodeunit.tests %>',
            tasks: 'default',
            styles: {
                files: ['app/styles/less/*.less'], // which files to watch
                tasks: ['less']
            }
        },
less: {
            development: {
                options: {
                    paths: ["app/styles/less"],
                    yuicompress: true
                },
                files: {
                    // target.css file: source.less file
                    "app/styles/main.css": "app/styles/less/main.less"
                }
            }
        },

grunt.loadNpmTasks('grunt-contrib-less');

grunt.registerTask('default', ['jshint', 'clean', 'copy', 'useminPrepare', 'ngtemplates', 'concat', 'uglify', 'cssmin', 'usemin', 'nodeunit', 'less']);

运行grunt之后,我有这个错误:

>> No "less" targets found.
Warning: Task "less" failed. Use --force to continue.

我如何解决这个问题?

1 个答案:

答案 0 :(得分:0)

不确定您提到的是什么,但我使用以下内容并且它正在运行:

watch {
  ..,
  less: {
    files: ['<%= config.app %>/styles/{,*/}*.less'],
    tasks: ['less']
  },
},

....

less: {
  production: {
    options: {
      paths: ['dist/styles'],
      cleancss: false
    },
    files: {
      '.tmp/styles/main.css': 'app/styles/main.less'
    }
  }
},