Skip to content

Instantly share code, notes, and snippets.

@krasenslavov
Created December 27, 2021 21:19
Show Gist options
  • Save krasenslavov/ae3fb684a1a1cb14402cba3f49624a48 to your computer and use it in GitHub Desktop.
Save krasenslavov/ae3fb684a1a1cb14402cba3f49624a48 to your computer and use it in GitHub Desktop.
How to Setup JS and CSS Environment Files (no external libraries)
<?php
ob_start();
include 'utils.mjs';
include 'module1.mjs';
include 'module2.mjs';
include 'module3.mjs';
$data = ob_get_clean();
$expressions = array(
'MULTILINE_COMMENT' => '\Q/*\E[\s\S]+?\Q*/\E',
'SINGLELINE_COMMENT' => '(?:http|ftp)s?://(*SKIP)(*FAIL)|//.+',
'WHITESPACE' => '^\s+|\R\s*'
);
foreach ($expressions as $key => $expr) {
$data = preg_replace('~' . $expr . '~m', '', $data);
}
echo $data;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment