【问题标题】:Grunt and Less. No «less» targets found?咕噜声和更少。没有找到«less»目标?
【发布时间】:2015-07-28 13:01:03
【问题描述】:

我使用 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 less 后,我有这个错误:

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

我该如何解决这个问题?

【问题讨论】:

    标签: javascript angularjs gruntjs yeoman


    【解决方案1】:

    不确定你提到了什么,但我正在使用以下内容并且它正在工作:

    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'
        }
      }
    },
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-04-18
      • 2015-05-25
      • 1970-01-01
      • 2015-04-13
      • 2013-03-15
      • 1970-01-01
      • 2015-08-03
      相关资源
      最近更新 更多