【问题标题】:grunt setup on windowsWindows 上的 grunt 设置
【发布时间】:2014-02-07 19:30:27
【问题描述】:

我在 Windows 8 上安装 grunt。我的 gruntfile.js 非常简单:

module.exports = function(grunt) {
    stylus: {

            files: {
                'build/style.css': ['styles/style.styl'],
            }

    };
    autoprefixer: {

    // prefix the specified file
    single_file: {
      options: {
        // Target-specific options go here.
      }
      src: 'build/style.css';
      dest: 'build/styles.css';
    };
  };

    grunt.loadNpmTasks('grunt-autoprefixer');
    grunt.loadNpmTasks('grunt-contrib-stylus');

    grunt.registerTask('default', ['stylus']);
    grunt.registerTask('stylus', ['stylus']);
    grunt.registerTask('ap', ['autoprefixer']);
};

我在咕噜咕噜地跑,得到错误:

X:\PROJEKTS\MY\test\Gruntfile.js:5 'build/style.css': ['styles/style.styl'] ^ 正在加载“Gruntfile.js”任务...错误

SyntaxError: Unexpected token : Warning: Task "default" not found.使用 --force 继续。

由于警告而中止。

请帮帮我

【问题讨论】:

    标签: gruntjs stylus


    【解决方案1】:

    这一切都搞砸了,甚至不是有效的 javascript :-) - 你缺少一个初始化配置。

    首先修复它:

    module.exports = function(grunt) {
    grunt.config.init({
      stylus: {
    
            files: {
                'build/style.css': ['styles/style.styl'],
            }
    
      },
      autoprefixer: {
        // prefix the specified file
        single_file: {
          options: {
            // Target-specific options go here.
          },
          src: 'build/style.css',
          dest: 'build/styles.css'
        }
      }
    });
    
    grunt.loadNpmTasks('grunt-autoprefixer');
    grunt.loadNpmTasks('grunt-contrib-stylus');
    
    grunt.registerTask('default', ['stylus']);
    grunt.registerTask('stylus', ['stylus']);
    grunt.registerTask('ap', ['autoprefixer']);
    };
    

    【讨论】:

      猜你喜欢
      • 2013-06-08
      • 2015-11-19
      • 2013-05-19
      • 1970-01-01
      • 1970-01-01
      • 2016-01-05
      • 2015-04-05
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多