Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revamp the CLI bin and add documentation to the readme #388

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

kodie
Copy link

@kodie kodie commented Dec 30, 2021

I'm using this package for a few different projects and I didn't even realize that there was an included CLI tool.

However, I needed the CLI tool to actually create the files rather than just echo the minified contents to STDOUT, so this led me to revamp the CLI tool.

This PR does a few things:

  1. Combines the minifycss and minifyjs commands into a single minify command (A breaking change for anyone currently using the CLI tool).
  2. Adds the ability to define an --ouput or -o option to have the minified contents written to a file (And if no output is defined, it'll echo the minified contents to STDOUT just like before).
  3. Adds the ability for multiple input files to be minified into each of their own output files (ex. -o "/path/to/minified/*.min.js")
  4. Adds the --import-ext, --gzip, and --max-import-size options to be able to use those features with the CLI tool.
  5. Adds the ability to pass multiple input files to be combined and minified together.
  6. Adds documentation about the CLI tool to the readme.
  7. Adds a help option to the CLI tool.

So now, you can do something like this:

bin/minify tests/js/sample/source/*.js -o test.js tests/css/sample/convert_relative_path/source/*.css -o test.css

and you'll end up with a test.js and test.css file.

This will come in handy as a dev tool for projects. For example, I could add a build script to the composer.json file of my package:

{
  "scripts": {
    "build": "vendor/bin/minify source1.js source2.js -o build.min.js"
  },
  "require-dev": {
    "matthiasmullie/minify": "^1.3.63"
  }
}

What's also nice about this is that other than swapping out the minifycss and minifyjs commands for minify it'll still function exactly the same as before unless you specifically decide to use some of the newly added options.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant