2014-12-02 3 views
0

Попытка получить Grunt для Concat мои CSS файлов в один под названием production.cssGruntfile.js задачи ... ОШИБКА

Вот выход из командной строки

C:\Users\josha\Desktop\Repos\AJAX Project - Grunt Test>grunt 

C:\Users\josha\Desktop\Repos\AJAX Project - Grunt Test\Gruntfile.js:2 
    "name": "AjaxPmodule.exports = function(grunt) { 
     ^
Loading "Gruntfile.js" tasks...ERROR 
>> SyntaxError: Unexpected token : 
Warning: Task "default" not found. Use --force to continue. 

Aborted due to warnings. 

C:\Users\josha\Desktop\Repos\AJAX Project - Grunt Test>grunt 

C:\Users\josha\Desktop\Repos\AJAX Project - Grunt Test\Gruntfile.js:2 
    "name": "AjaxPmodule.exports = function(grunt) { 
     ^
Loading "Gruntfile.js" tasks...ERROR 
>> SyntaxError: Unexpected token : 
Warning: Task "default" not found. Use --force to continue. 

Aborted due to warnings. 

C:\Users\josha\Desktop\Repos\AJAX Project - Grunt Test> 

Вот мой Gruntfile

{ 
    "name": "AjaxPmodule.exports = function(grunt) { 

    // 1. All configuration goes here 
    grunt.initConfig({ 
     pkg: grunt.file.readJSON('package.json'), 

concat: { 
    dist: { 
     src: [ 
      'css/*.css', // All JS in the libs folder 
     ], 
     dest: 'css/production.css', 
    } 
} 

    }); 

    // 3. Where we tell Grunt we plan to use this plug-in. 
    grunt.loadNpmTasks('grunt-contrib-concat'); 

    // 4. Where we tell Grunt what to do when we type "grunt" into the terminal. 
    grunt.registerTask('default', ['concat']); 

};roject", 
    "version": "0.1.0", 
    "devDependencies": { 
    "grunt": "~0.4.1", 
    "grunt-contrib-concat": "^0.5.0" 
    } 
} 

Я использую grunt-contrib-concat для согласования моих файлов. Версия «^ 0.5.0»

ответ

1

Вы по какой-то причине получили дополнительный текст в свой файл. Он должен начинаться с module.exports, и у вас также есть что-то дополнительное в конце.

Я думаю, что вы сделали, в основном, чтобы вставить код черновую в фрагмент кода, который выглядит как package.json:

{ 
    "name": "ajaxProject", 
    "version": "0.1.0", 
    "devDependencies": { 
     "grunt": "~0.4.1", 
     "grunt-contrib-concat": "^0.5.0" 
    } 
} 

Попробуйте это:

module.exports = function(grunt) { 

    // 1. All configuration goes here 
    grunt.initConfig({ 
     pkg: grunt.file.readJSON('package.json'), 

     concat: { 
      dist: { 
       src: [ 
        'css/*.css', // All JS in the libs folder 
       ], 
       dest: 'css/production.css', 
      } 
     } 

    }); 

    // 3. Where we tell Grunt we plan to use this plug-in. 
    grunt.loadNpmTasks('grunt-contrib-concat'); 

    // 4. Where we tell Grunt what to do when we type "grunt" into the terminal. 
    grunt.registerTask('default', ['concat']); 

} 
+0

Это работало !!! Спасибо ... но что другое? ха-ха. Принять как ответ – onTheInternet

+0

Отлично, обновите причину. Как уже было сказано, похоже, что вы ввели свой текст grunt в то, что выглядит как фрагмент package.json. – cbass

Смежные вопросы