thedava / gruntfile-generator
此包已被弃用且不再维护。未建议替代包。
基于PHP的Gruntfile.js生成器
1.0
2015-09-24 22:21 UTC
Requires
- php: >=5.3
- mustache/mustache: ^2.9
- pear/console_color2: ^0.1.2
This package is not auto-updated.
Last update: 2022-02-01 12:51:37 UTC
README
基于PHP的Gruntfile.js生成器
安装
php composer.phar require thedava/gruntfile-generator
控制台命令
php bin/gruntfile --config=your_grunt_config.php --gruntfile=Gruntfile.js
基本配置文件
<?php return array( Gruntfile::CONFIG_IMPORTS => array( 'your-grunt-import' ), Gruntfile::CONFIG_TASKS => array( 'your_task' => array( 'some:target' ) ), Gruntfile::CONFIG_TARGETS => array( 'some' => array( 'target' => array( 'do' => 'something' ) ) ) );
Gruntfile生成
将gruntfile-generator添加为您的grunt配置的目标,以获得最大效率。您只需要导入grunt-exec。
<?php return array( Gruntfile::CONFIG_IMPORTS => array( 'grunt-exec' ), Gruntfile::CONFIG_TASKS => array( 'gruntfile' => array( 'exec:gruntfile' ) ), Gruntfile::CONFIG_TARGETS => array( 'exec' => array( 'gruntfile' => 'php bin/gruntfile --config=this_file.php --gruntfile=Gruntfile.js' ) ) );
在命令行中手动运行exec目标一次,您的Gruntfile将被生成。现在您可以使用grunt gruntfile从配置更新您的Gruntfile。
扩展配置文件
您可以将配置分离到多个文件中,并使用Gruntfile类构建有效的gruntfile生成器配置。
假设您的结构如下所示
root
|-- bin
| |-- gruntfile
|
|-- config
| |-- grunt.config.php
| |-- tasks
| | |-- task1.config.php
| | |-- task2.config.php
| | |-- ...
您的grunt.config.php可能如下所示
<?php $configFiles = glob(__DIR__.'/tasks/*.config.php'); return Gruntfile::mergeConfigs($configFiles);
现在您可以为每个任务/目标/需要执行的操作添加一个新的文件。这可以使您的配置简单且干净。Gruntfile生成器将在最后构建一个单一的Gruntfile。