문제

여기 내 그런트 파일이 있습니다.제이에스

module.exports = function(grunt) {
    grunt.initConfig({
        pkg: grunt.file.readJSON("package.json"),

        uglify: {
          options: {
            mangle: true
          }
          build: {
            src: "js/*.js",
            dest: "js/min/script.js"
          }
        }

    });

    grunt.loadNpmTasks("grunt-contrib-uglify");

    grunt.registerTask('default', [uglify]);

};

여기 내 패키지가 있습니다.나는 도망 쳤다. npm install 이미 내 그런트 파일에서 사용할 모든 플러그인과 함께,그런트-인위적-추악함은 그 중 하나입니다.

{
  "name": "bootbuckle",
  "version": "0.1.0",
  "engines": {
    "node": ">= 0.10.0"
  },
  "devDependencies": {
    "grunt": "~0.4.2",
    "grunt-contrib-watch": "~0.5.3",
    "grunt-contrib-sass": "~0.6.0",
    "grunt-csscomb": "~2.0.1",
    "grunt-contrib-htmlmin": "~0.1.3",
    "grunt-contrib-imagemin": "~0.4.1",
    "grunt-contrib-uglify": "~0.2.7"
  }
}

내가 단순히 달릴 때 grunt 터미널에서-여기에 오류가 있습니다

  build: {
  ^^^^^
Loading "Gruntfile.js" tasks...ERROR
>> SyntaxError: Unexpected identifier
Warning: Task "default" not found. Use --force to continue.
Aborted due to warnings.

당신이 제공 할 수 있습니다 어떤 도움을 사전에 감사합니다.


편집 마티의 지침에 따라 누락 된 쉼표를 삽입 한 새로운 오류가 발생합니다

Loading "Gruntfile.js" tasks...ERROR
>> ReferenceError: uglify is not defined
Warning: Task "default" not found. Use --force to continue.
Aborted due to warnings.
도움이 되었습니까?

해결책

당신은 여기에 쉼표를 놓쳤다:

    uglify: {
      options: {
        mangle: true
      }, // <-------
      build: {
        src: "js/*.js",
        dest: "js/min/script.js"
      }
    }

편집:자프레스콧에 의해 게시 된 바와 같이,당신은 문자열로 추함 작업을 정의해야합니다.

grunt.registerTask('default', ["uglify"]);

다른 팁

이 같은 시도

  grunt.registerTask('default', ["uglify"]);
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top