2014-08-30 35 views
0

我使用这个guntfile.js并且对我的项目工作正常,但我不明白一些事情。grunt了解任务脚本和php

'use strict'; 

var  bsoptions={ 
//porta di lavoro del livereload standard 
port: 35729, 
//path del nostro tema 
themepath: "wp-content/themes/rttheme18", 
//host inserito nell'installazione di wp 
http_host: "www.bottonisworld.localhost"} ; 
module.exports = function(grunt) { 
// inseriamo la configurazione di grunt 
grunt.initConfig({ 
    //carichiamo il file json 
    pkg: grunt.file.readJSON('package.json'), 
    //banner inseribile nei file nel caso di concat plugin ad esempio 
    banner: "Nome pacchetto <%= pkg.name %>", 
    //proprietà custom per mostrare il loro utilizzo nei task successivi con la sintassi di grunt engine 
    BSbasePath: bsoptions.themepath, 
    BSHTTP_HOST: bsoptions.http_host, 
    //____________ task "watch" _________ 
    watch: { 
     // dichiariamo quali file deve guardare watch 
     scripts:{ 
      files:[ 
       '<%= BSbasePath %>/**/*.html', 
     '<%= BSbasePath %>/**/*.css','<%= BSbasePath %>/**/*.{png,jpg,jpeg,gif,webp,svg}']}, 
php: { 
      files: ['<%= BSbasePath %>/**/*.php'] 
     }, 
     //opzioni del task watch 
     options: { 
      //usiamo il livereload 
      livereload: true, 
      //inseriamo il keepalive 
      keepalive:true, 
      spawn: false 
     } 
    } 
}); 
//loading dei plugin necessari al nostro lavoro 
grunt.loadNpmTasks('grunt-contrib-watch'); 
grunt.loadNpmTasks('grunt-contrib-livereload'); 
//registrazione del task di lavoro che esegue ogni singolo task 
grunt.registerTask('default', function() { 
grunt.task.run([ 
    'watch' 
]); 
}); 
}; 

我想已了解 “脚本” 和 “PHP” 的任务。我在谷歌搜索,但没有找到任何东西,有人可以解释我或告诉我在哪里可以找到这些任务/目标的文件?

回答

0

该文件包含一个具有JSON格式初始化变量的函数。 见http://www.w3schools.com/json/ 和JSON通配符 http://goessner.net/articles/JsonPath/

脚本:这包括符合给定模式“/**/*.html”你BSbasePath变量下的所有文件。

scripts:{ 
     files:[ 
      '<%= BSbasePath %>/**/*.html', 
      '<%= BSbasePath %>/**/*.css', 
      '<%= BSbasePath %>/**/*.{png,jpg,jpeg,gif,webp,svg}' 
     ] 
    }, 

PHP:这包括所有符合模式/**/*.php起始路径BSbasePath下的文件。这些文件的结尾都是.html,.css,.png,.jpg,.jpeg,.gif,.webp,.svg。

php: { 
     files: ['<%= BSbasePath %>/**/*.php'] 
    }, 

星号*表示任何字符和数字,甚至特殊字符。这意味着将读入所有文件并与通配符进行比较。只有匹配的文件将被使用。这些将是名称末尾有'.php'的文件。

The description for the configuration is here

+0

正确的,但 我想知道在哪里可以找到任务“脚本”和“PHP”。如果我想使用的文档“ASP”文件我必须声明: ASP: {'<%= BSbasePath%>/**/*。asp'] } 如果是,那么文档在哪里? :( – lbottoni 2014-08-30 14:09:52

+0

你有一个例子在这里http://scotch.io/bar-talk/a-simple-guide-to-getting-started-with-grunt 姓名'脚本'和'PHP'只是名字选择。我认为这并不重要,Grant如何命名它,Grant将会收集这些文件并且处理这些文件,Grant收集这些文件,只需要命名Javascript脚本需要的文件和PHP执行的文件被称为'php'。 – 2014-08-30 15:28:54