reisraff/phulp-inject 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

reisraff/phulp-inject

Composer 安装命令:

composer require reisraff/phulp-inject

包简介

The inject addon for phulp

README 文档

README

The inject addon for PHULP.

It's like gulp-inject with some modifications.

Install

$ composer require reisraff/phulp-inject

Usage

The target file src/index.html:

Each pair of comments are the injection placeholders

<!DOCTYPE html>
<html>
<head>
  <title>App</title>
  <!-- inject:css -->
  <!-- endinject -->
</head>
<body>

  <!-- inject:js -->
  <!-- endinject -->
</body>
</html>

The phulpfile.php:

<?php

use Phulp\Inject\Inject;

$phulp->task('inject', function ($phulp) {
    $injectionFiles = $phulp->src(['src/'], '/(js|css)$/', true);

    $phulp->src(['src/'], '/html$/')
        // injecting
        ->pipe(new Inject($injectionFiles->getDistFiles()))
        // write the html file with the injected files
        ->pipe($phulp->dest('dist/'));
});

dist/index.html after running phulp inject:

<!DOCTYPE html>
<html>
<head>
  <title>App</title>
  <!-- inject:css -->
  <link rel="stylesheet" href="css/sytle.css">
<link rel="stylesheet" href="css/style2.css">
<!-- endinject -->
</head>
<body>

  <!-- inject:js -->
  <script src="js/script.js"></script>
<script src="js/script2.js"></script>
<!-- endinject -->
</body>
</html>

Options

Set in the constructor.

tagname : default: inject, it is used to define a global tagname as placeholder.

starttag : default: null, it is used to replace the default starttag

endtag : default: null, it is used to replace the default endtag

filterFilename : default: null, it is used to replace the filename

<?php

use Phulp\Inject\Inject;

$cssMinifier = new Inject(
  $distFiles,
  [
    'tagname' => 'replace-inject',
    'starttag' => '<-- replace-inject -->',
    'endtag' => '<-- endreplace-inject -->,
    'filterFilename' => function ($filename) {
      return 'path/' . $filename;
    },
  ]
);

统计信息

  • 总下载量: 43
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-10-27

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固