New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

smush

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

smush

Utility package to smush css and js files

  • 0.0.6
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
decreased by-75%
Maintainers
1
Weekly downloads
 
Created
Source

Node Smush

Install

$ npm install smush

Build Status

Utility package to help smush css and js files. Currently supports jade template language, but can easily be extended to support other formats.

Minified files are placed in options.target dir, defaults to public/css/min and public/js/min for css and js files respectively.

The generated .jade files are placed alongside the .tmpl files.

Default CSS & JS options

Please check default options for search and replace patterns listed below or in the index.js file. You just need to update the options to suit your needs.

var defaults = {
  extension: '.tmpl',
  jade: {
    extension: '.jade',
    comment: '//- This is a generated file. Make your changes to the .tmpl file instead.\n\n',
    css: {
      pattern: /link\(rel=\"stylesheet\", href=\"(.*)\.css\"/,
      replacePattern: '<PLACEHOLDERFORMINIFIEDFILE>',
      extension: '.css',
      source: 'public',
      target: 'public/css/min/'
    },

    js: {
      pattern: /script\(src\=\"(.*)\.js\"/,
      replacePattern: '<PLACEHOLDERFORMINIFIEDFILE>',
      extension: '.js',
      source: 'public',
      target: 'public/js/min/'
    }
  }
};

Smush CSS

Use smush.css(options, callback) to smush css files. template is a required field that species the .tmpl file to smush.

Example

var smush = require('smush');
smush.css({
  template: 'test/sample/css/styles',
  pattern: /link\(rel=\"stylesheet\",href=\"(.*)\.css\"/,
  source: 'test/sample/',
  target: 'test/sample/min/'
}, callback);

Smush JS

Use smush.js(options, callback) to smush javascript files. template is a required field that species the .tmpl file to smush.

Example

smush.js({
  template: 'test/sample/js/scripts',
  pattern: /script\(src\=\'(.*)\.js\'/,
  source: 'test/sample/',
  target: 'test/sample/min/'
}, callback);

Test Code

Run npm test or node path/to/smush/index.js to verify if minify is working. Please check files under test dir for a sample implementation.

Keywords

FAQs

Package last updated on 22 Jan 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc