2016-11-25 7 views
-1

HTMLファイル内でJavascriptを使用しようとしています。だから、私はJSファイルのマクロを参照するために依存性を置き換えることを使用しています。設定でGrunt Syntaxエラーが発生しました

gruntfile.js設定でreplace関数を追加して以来、構文エラーが発生しています。

私が紛失していることは非常に簡単だと確信しています。うまくいけば、誰かが助けることができますか?あなたはinitConfigための不一致括弧を持って事前

答えて

0

module.exports = function (grunt) { 
 

 
    var allJS = ['src/*.js']; 
 

 
    // Project configuration. 
 
    grunt.initConfig({ 
 

 
     pkg: grunt.file.readJSON('package.json'), 
 

 
     jshint: { 
 
      options: { 
 
       scripturl: true 
 
      }, 
 
      files: ['gruntfile.js', allJS] 
 
     }, 
 
replace: { 
 
\t \t \t \t  normal: { 
 
\t \t \t \t   options: { 
 
\t \t \t \t   patterns: [ 
 
\t \t \t \t    { 
 
\t \t \t \t    match: 'scriptmacro', 
 
\t \t \t \t    replacement: '<%= grunt.file.read("tmp/tmpmoatscript.js") %>' 
 
\t \t \t \t    }, 
 
\t \t \t \t   ] 
 
\t \t \t \t   }, 
 
\t \t \t \t   files: [ 
 
\t \t \t \t   { 
 
\t \t \t \t    expand: true, 
 
\t \t \t \t    flatten: true, 
 
\t \t \t \t    src: ['src/index.html'], 
 
\t \t \t \t    dest: 'dist' 
 
\t \t \t \t   } 
 
\t \t \t \t   ] 
 
\t \t \t \t  }, 
 

 
     clean: { 
 
      dist: ['dist'] 
 
     }, 
 

 
     uglify: { 
 
      'main': { 
 
       options: { 
 
        "banner": "", 
 
        enclose: { 
 
         window: "window", 
 
         document: "document" 
 
        }, 
 
       }, 
 

 
       files: { 
 
        'dist/min-moatscript.txt': 'src/moatscript.txt', 
 
       } 
 
      } 
 
     } 
 
\t \t 
 
    }); 
 

 
    // Load the plugin that provides the "uglify" task. 
 
    grunt.loadNpmTasks('grunt-contrib-jshint'); 
 
    grunt.loadNpmTasks('grunt-contrib-uglify'); 
 
    grunt.loadNpmTasks('grunt-contrib-clean'); 
 
    grunt.loadNpmTasks('grunt-contrib-replace'); 
 

 

 
    // Default task(s). 
 
    grunt.registerTask('default', ['jshint', 'clean', 'uglify','replace',]); 
 

 
};

感謝。

構文エラーについては、IDE/jshint.comにアクセスして調べることができます。

module.exports = function(grunt) { 
 

 
    var allJS = ['src/*.js']; 
 

 
    // Project configuration. 
 
    grunt.initConfig({ 
 

 
    pkg: grunt.file.readJSON('package.json'), 
 

 
    jshint: { 
 
     options: { 
 
     scripturl: true 
 
     }, 
 
     files: ['gruntfile.js', allJS] 
 
    }, 
 
    replace: { 
 
     normal: { 
 
     options: { 
 
      patterns: [{ 
 
      match: 'scriptmacro', 
 
      replacement: '<%= grunt.file.read("tmp/tmpmoatscript.js") %>' 
 
      }, ] 
 
     }, 
 
     files: [{ 
 
      expand: true, 
 
      flatten: true, 
 
      src: ['src/index.html'], 
 
      dest: 'dist' 
 
     }] 
 
     }, 
 

 
     clean: { 
 
     dist: ['dist'] 
 
     }, 
 

 
     uglify: { 
 
     'main': { 
 
      options: { 
 
      "banner": "", 
 
      enclose: { 
 
       window: "window", 
 
       document: "document" 
 
      }, 
 
      }, 
 

 
      files: { 
 
      'dist/min-moatscript.txt': 'src/moatscript.txt', 
 
      } 
 
     } 
 
     } 
 

 
    } 
 
    }); 
 

 
    // Load the plugin that provides the "uglify" task. 
 
    grunt.loadNpmTasks('grunt-contrib-jshint'); 
 
    grunt.loadNpmTasks('grunt-contrib-uglify'); 
 
    grunt.loadNpmTasks('grunt-contrib-clean'); 
 
    grunt.loadNpmTasks('grunt-contrib-replace'); 
 

 
    // Default task(s). 
 
    grunt.registerTask('default', ['jshint', 'clean', 'uglify', 'replace', ]); 
 

 
};

関連する問題