usemin-lib
Replaces references to non-optimized scripts or stylesheets into a set of HTML files (or any templates/views) available as a library
Last updated 9 years ago by jbavari .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install usemin-lib 
SYNC missed versions from official npm registry.

usemin-lib

Library version of usemin. For purists, those who doesn't use build tools like Grunt and Gulp, but just use NPM as their build tool.

Getting started

To use this now, install with this command:

npm install usemin-lib

From GitHub

git clone https://github.com/driftyco/usemin-lib.git
cd usemin-lib
npm install
npm link

Usage

var fs = require('fs'), path = require('path');
var indexHtmlFilePath = path.join('./', 'index.html');
var useminLib = require('usemin-lib');
var content = fs.readFileSync(indexHtmlFilePath).toString();
var blocks = useminLib.getBlocks(indexHtmlFilePath, content, true /* removeLivereloadBool */);
var process = useminLib.processBlocks(blocks, './www/dist/index.html' /* destDir */);
var output = useminLib.getHTML(content, blocks, true /* htmlminBool */);
console.log('minified stuffs:', output);

Example HTML

<!-- build:css css/main.js -->
<link rel="stylesheet" href="css/main.css">
<link rel="stylesheet" href="css/modules.css">
<!-- endbuild -->

<!-- build:js js/main.js -->
<script src="js/app.js"></script>
<script src="js/controllers.js"></script>
<!-- endbuild -->

<!-- build:js js/main.js -->
<script defer async src="js/app.js"></script>
<script defer async src="js/controllers.js"></script>
<!-- endbuild -->

<script>document.write('<script src="http://' + (location.host || 'localhost').split(':')[0] + ':35729/livereload.js?snipver=1"></' + 'script>')</script>

Running the command with --rmlr true will output:

<link rel="stylesheet" href="css/main.js">
<script src="js/main.js"></script>
<script defer async src="js/main.js"></script>

License

MIT license

Current Tags

  • 0.0.5                                ...           latest (9 years ago)

5 Versions

  • 0.0.5                                ...           9 years ago
  • 0.0.4                                ...           9 years ago
  • 0.0.3                                ...           9 years ago
  • 0.0.2                                ...           9 years ago
  • 0.0.1                                ...           9 years ago
Maintainers (1)
Downloads
Total 3
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (5)
Dev Dependencies (2)
Dependents (1)

© 2010 - cnpmjs.org x YWFE | Home | YWFE