https://github.com/nelsyeung/usemin-cli
Replaces references to non-optimized scripts or stylesheets into a set of HTML files (or any templates/views)
https://github.com/nelsyeung/usemin-cli
build-tool cli html javascript nodejs usemin usemin-cli
Last synced: 5 months ago
JSON representation
Replaces references to non-optimized scripts or stylesheets into a set of HTML files (or any templates/views)
- Host: GitHub
- URL: https://github.com/nelsyeung/usemin-cli
- Owner: nelsyeung
- License: mit
- Created: 2015-06-23T18:56:46.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2023-04-16T15:19:15.000Z (about 3 years ago)
- Last Synced: 2025-10-19T08:36:38.610Z (8 months ago)
- Topics: build-tool, cli, html, javascript, nodejs, usemin, usemin-cli
- Language: JavaScript
- Size: 298 KB
- Stars: 23
- Watchers: 1
- Forks: 9
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# usemin-cli
[](https://travis-ci.org/nelsyeung/usemin)
[](https://www.npmjs.com/package/usemin-cli)
[](https://www.npmjs.com/package/usemin-cli)
> CLI version of usemin. For _purists_, those who don't use build tools like [Grunt](https://github.com/yeoman/grunt-usemin) and [Gulp](https://github.com/zont/gulp-usemin), but just use NPM as their build tool.
## Getting started
Install with npm:
```
npm install usemin-cli
```
## API
[usemin](https://github.com/nelsyeung/usemin) - API for this module.
## Usage
```
usemin [input.html] [--dest|-d dir] [--output|-o output.html] [options]
```
### Example commands
```
usemin src/index.html --dest dist --output dist/index.html
usemin src/index.html -d dist -o dist/index.html
usemin src/index.html -d dist > dist/index.html
usemin src/index.html -d dist -o dist/index.html --htmlmin true --rmlr true
usemin src/index.html -d dist -o dist/index.html --htmlmin true -c config.js
```
### Available options
```
--htmlmin - Also minifies the input HTML file (Boolean)
--rmlr, --removeLivereload - Remove livereload script (Boolean)
--noprocess - Do not process files, just replace references (Boolean)
-c, --config - Supply a configurations file for UglifyJS, CleanCSS and HTML minifier.
--listblocks - Write blocks to stdout or filename.json.
E.g., --listblocks // print to stdout
--listblocks blocks.json // write to blocks.json
```
### Example HTML
#### Blocks
Blocks are expressed as:
```html
... HTML Markup, list of script / link tags.
```
- **pipelineId**: pipeline id for options or remove to remove a section
- **alternate search path**: (optional) By default the input files are relative to the treated file. Alternate search path allows one to change that
- **path**: the file path of the optimized file, the target output
```html
document.write('<script src="http://' + (location.host || 'localhost').split(':')[0] + ':35729/livereload.js?snipver=1"></' + 'script>')
```
Running the command with `--rmlr true` will output:
```
```
#### Alternate search path
```html
```
### Config file
Please check the relevant documentations for the available options: [ UglifyJS](https://github.com/mishoo/UglifyJS2), [CleanCSS](https://github.com/jakubpawlowicz/clean-css) and [HTML minifier](https://github.com/kangax/html-minifier).
```JavaScript
module.exports = {
uglifyjs: {
// ... UglifyJS API options
},
cleancss: {
// ... CleanCSS API options
},
htmlminifier: {
// ... HTML minifier API options
}
}
```
## License
[MIT license](http://opensource.org/licenses/MIT.php)