PHPackages                             itsahappymedium/fec - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [CLI &amp; Console](/categories/cli)
4. /
5. itsahappymedium/fec

ActiveLibrary[CLI &amp; Console](/categories/cli)

itsahappymedium/fec
===================

A PHP Command Line tool that makes it easy to compile, concat, and minify front-end Javascript and CSS/SCSS dependencies.

0.2.2(2y ago)21.3k↓20%[4 issues](https://github.com/itsahappymedium/fec/issues)MITPHPPHP ^7.3|^8.0

Since Sep 15Pushed 2y ago1 watchersCompare

[ Source](https://github.com/itsahappymedium/fec)[ Packagist](https://packagist.org/packages/itsahappymedium/fec)[ Docs](https://github.com/itsahappymedium/fec)[ RSS](/packages/itsahappymedium-fec/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (4)Versions (9)Used By (0)

Front End Compiler
==================

[](#front-end-compiler)

[![packagist package version](https://camo.githubusercontent.com/e8d883577b2ae11dec607f934f48f074dc99a471db72bb27ce6518d55de932cc/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6974736168617070796d656469756d2f6665632e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/itsahappymedium/fec)[![packagist package downloads](https://camo.githubusercontent.com/dbb2f482862b4f081598558c98734026d8349a917b744bcf861e55e29b718ec7/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6974736168617070796d656469756d2f6665632e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/itsahappymedium/fec)[![license](https://camo.githubusercontent.com/25ddeb4743a5e9ae38aee1843b6e7763a7549384fcdd1462ac7778bb97250338/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6974736168617070796d656469756d2f6665632e7376673f7374796c653d666c61742d737175617265)](license.md)

A PHP Command Line tool that makes it easy to compile, concat, and minify front-end Javascript and CSS/SCSS dependencies.

The [minify](https://github.com/matthiasmullie/minify) and [scssphp](https://github.com/scssphp/scssphp) packages do all of the heavy lifting, this tool simply combines the two into a single CLI tool with some extra features.

Installation
------------

[](#installation)

### To a package (local)

[](#to-a-package-local)

```
composer require-dev itsahappymedium/fec
./vendor/bin/fec help

```

### To your system (global)

[](#to-your-system-global)

```
composer global require itsahappymedium/fec
fec help

```

Usage
-----

[](#usage)

Running FEC without any arguments will load files from a `fec.json` file that is structured like so:

```
{
  "compile": {
    "css": {
      "build/main.min.css": "scss/main.scss",
      "build/vendor.min.css": [
        "gpm_modules/kazzkiq/balloon.css/src/balloon.scss",
        "scss/vendor/*.scss"
      ]
    },
    "js": {
      "build/main.min.js": "js/*.js",
      "build/vendor.min.js": [
        "gpm_modules/kraaden/autocomplete/autocomplete.js",
        "js/vendor/*.js"
      ]
    }
  }
}
```

### Options

[](#options)

File paths can be passed to FEC to compile those specific files.

- `--css--output` / `-c` - Define the path to a single file to concat all CSS/SCSS files into one file, or define a path to a directory to process each file individually with the `.min.css` extension.
- `--js--output` / `-j` - Define the path to a single file to concat all JS files into one file, or define a path to a directory to process each file individually with the `.min.js` extension.
- `--no-minify` / `-n` - Don't do any minification, just concat files.
- `--path` / `-p` - Defines a path to either a JSON file, or a directory where a `fec.json` file is located.
- `--remove-important-comments` / `-r` - Remove all comments, including those that are marked as important. This option also accepts a file name, or the last part of it's file path to only remove important comments from that file. You can also prepend the file name with a `!` to remove important comments from all files but that file. You can pass multiple files by separating them with a comma (`,`).
- `--scss-import-path` / `-s` - Define an additional path to check for SCSS imports in. You can pass multiple paths by separating them with a comma (`,`).
- `--watcher` / `-w` - Define a path to point the [EventSource](https://developer.mozilla.org/en-US/docs/Web/API/EventSource) to that will be injected into your JavaScript so that the page is refreshed when files are updated while running the `watch` command. (See `watch` command section below for more information)

#### Examples

[](#examples)

```
fec --js-output build/main.min.js js/*.js

fec --css-output build/main.min.css --js-output build/main.min.js scss/*.scss js/*.js

```

### The `watch` command

[](#the-watch-command)

Starts a process that watches for file changes and recompiles them as needed. This command will do an initial compile just to make sure everything is up to date.

#### The Watcher

[](#the-watcher)

FEC has the ability to automatically refresh your website while running the `watch` command (much like how [Browsersync](https://github.com/Browsersync/browser-sync) works). Simply create a `watcher.php` (or whatever you want to call it) somewhere that is accessible by your website, and place the following code in there:

```
