0.0.2 • Published 3 years ago

@tgrwb/gulp-php v0.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

@tgrwb/gulp-version

Copy, rename and replace for *.php

install

npm i @tgrwb/gulp-php

gulpfile.js

const php = require('@tgrwb/gulp-php');

tgrwb.gulp.js (optional)

module.exports = {
	dirSrc: 'src',
	dirDist: 'dist',
	php_namespace: 'your\\namespace',
	php_wpTextdomain: 'your_textdomain'
};

tgrwb.gulp.php.js (optional)

const path = require('path');

module.exports = (baseParams)=>{

	const {dirSrc, dirDist, php_namespace, php_wpTextdomain} = baseParams;

	return {
		globs: `${dirSrc}/**/*.@(php|xml)`,
		rename: [ // rename file path
			{pattern: /(?:^|.*\/)_([^\/]+(?:\/|$))/, replacement: '$1'}
		],
		frep: [ // replace in files
			{pattern: /((?:\s|\\))src((?:;|\\))/g, replacement: `$1${php_namespace}$2`},
			{pattern: /((?:'|"))tgrwb_textdomain((?:_admin)?(?:'|"))/g, replacement: `$1${php_wpTextdomain}$2`}
		],
		dist: path.join(dirDist)
	};
};

Usage

const php = require('@tgrwb/gulp-php');
exports.php = php;

or

const {series, parallel} = require('gulp');
const php = require('@tgrwb/gulp-php');

exports.build = series(
	parallel(
		...,
		...,
		...
	),
	parallel(
		...,
		...,
		php,
		...
	)
);