Gruntfile.js观看

时间:2013-10-11 16:07:47

标签: wordpress sass gruntjs grunt-contrib-watch

所以我正在创建自己的Wordpress框架,并且正在使用grunt和sass。我是咕噜咕噜咕噜咕噜咕噜咕噜咕噜咕噜咕噜咕噜咕噜咕噜咕噜咕噜咕噜咕噜咕噜咕噜咕噜咕噜咕噜咕噜咕噜叫咕

我从roots.io获取Gruntfile.js文件作为起点。据我所知,我所拥有的一切都是正确的,但我对一些事情并不十分肯定。我删除了js的东西,因为我不会去看它,我添加了grunt-contrib-sass。

运行grunt watch时出现此错误:

 grunt watch

/Gruntfile.js:22
        watch: {
        ^^^^^
Loading "Gruntfile.js" tasks...ERROR
>> SyntaxError: Unexpected identifier
Warning: Task "watch" not found. Use --force to continue.

Aborted due to warnings.

下面是我的Gruntfile.js和我的package.json

Gruntfile.JS

'use strict';
module.exports = function (grunt) {

    grunt.initConfig({
        version: {
            options: {
                file: 'lib/scripts.php',
                css: 'assets/css/main.min.css',
                cssHandle: 'su_styles'
            }
        },
        sass: {
            dist: {
                options: {
                    style: 'compressed'
                },
                files: {
                    'assets/css/main.min.css': [
                    'assets/scss/app.scss'
                    ]
                }
            }
        },
        watch: {
            sass: {
                files: [
          'assets/scss/*.scss',
          'assets/scss/foundation/*.scss'
                ],
                tasks: ['sass', 'version']
            },
            livereload: {
                // Browser live reloading
                // https://github.com/gruntjs/grunt-contrib-watch#live-reloading
                options: {
                    livereload: false
                },
                files: [
          'assets/css/main.min.css',
          'templates/*.php',
          '*.php'
                ]
            }
        },
        clean: {
            dist: [
        'assets/css/main.min.css'
            ]
        }
    });

    // Load tasks
    grunt.loadNpmTasks('grunt-contrib-clean');
    grunt.loadNpmTasks('grunt-contrib-watch');
    grunt.loadNpmTasks('grunt-wp-version');
    grunt.loadNpmTasks('grunt-contrib-sass');

    // Register tasks
    grunt.registerTask('default', [
    'clean',
    'version',
    'sass'
    ]);
    grunt.registerTask('dev', [
    'watch'
    ]);

};

package.json - 取出一些东西来保护一点隐私

{
  "name": "sudoh",
  "version": "1.0.0",
  "author": "Brandon Shutter <brandon@brandonshutter.com>",
  "licenses": [
    {
      "type": "MIT",
      "url": "http://opensource.org/licenses/MIT"
    }
  ],
  "engines": {
    "node": ">= 0.10.0"
  },
  "devDependencies": {
    "grunt": "~0.4.1",
    "grunt-contrib-clean": "~0.5.0",
    "grunt-contrib-watch": "~0.5.3",
    "grunt-wp-version": "~0.1.0",
    "grunt-contrib-sass": "~0.5.0"
  }
}

提前感谢您的帮助。

1 个答案:

答案 0 :(得分:0)

我的设置似乎没有任何问题。我的代码编辑器(Brackets)出于任何原因添加了隐藏的字符,并导致语法错误。切换到Sublime并再次保存文件使其完美运行。

感谢大家的帮助。