【问题标题】:grunt understand task scripts and phpgrunt 理解任务脚本和 php
【发布时间】:2014-08-30 07:44:03
【问题描述】:

我使用这个 guntfile.js 并为我的项目工作正常,但我不明白一些事情。

'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'
]);
});
};

我想要理解“scripts”和“php”任务。我在谷歌搜索但没有找到任何东西,有人可以解释我或告诉我在哪里可以找到这些任务/目标的文档?

【问题讨论】:

    标签: php gruntjs task target watch


    【解决方案1】:

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

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

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

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

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

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

    The description for the configuration is here

    【讨论】:

    • 正确,但我想知道在哪里可以找到任务“脚本”和“php”的文档。如果我想使用“asp”文件,我必须声明:asp:{文件: ['/**/*.asp'] } 如果是,文档在哪里??? :(
    • 这里有一个例子scotch.io/bar-talk/a-simple-guide-to-getting-started-with-grunt 名称'scripts' 和'php' 只是选择的名称。我认为你如何命名它并不重要。格兰特会带他们去处理这些文件。格兰特收集这些文件。将 Javascript 'scripts' 所需的文件命名为有意义的文件,并将 PHP 执行的文件称为 'php'。
    猜你喜欢
    • 2016-03-13
    • 2023-03-08
    • 2014-09-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-03-05
    • 2012-05-14
    相关资源
    最近更新 更多