npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

uglify-js-minify-css-allfiles

v2.2.4

Published

you will be able to minify all files as same file names which is js or css

Downloads

337

Readme

NPM downloads NPM total downloads

|  Donate   | Your help is appreciated! Create a PR or just buy me a coffee | | ---------------------------------------------------------- | ---------------------------------------------------------------------------------------- |

uglify-js-minify-css-allfiles

A powerful tool to minify and obfuscate JavaScript and CSS files in your project.
It helps protect your code in deployment environments and makes it less recognizable to others, all through a simple CLI interface.
You can easily minify all files in a specific folder, with the option to exclude certain directories.

NPM


Table of Contents

Installation

Install with npm:

$ npm i uglify-js-minify-css-allfiles

Usage

  1. Basic usage (no Babel):

    import minifyAll from 'uglify-js-minify-css-allfiles';
    
    await minifyAll('./src/');
  2. Using options:

    import minifyAll from 'uglify-js-minify-css-allfiles';
    
    await minifyAll('./src/', {
      excludeFolder: 'node_modules',
      useBabel: {
        targets: 'chrome 40',
        modules: false,
        useBuiltIns: 'usage',
        corejs: 3,
      },
      useLog: {
        logDir: 'logs',
        retentionDays: 30,
        logLevel: 'info',
        dateFormat: 'YYYY-MM-DD',
        timeZone: 'UTC',
        logToConsole: true,
        logToFile: true,
      },
      jsMinifyOptions: {
        compress: {
          dead_code: true,
          drop_debugger: true,
          conditionals: true,
          evaluate: true,
          booleans: true,
          loops: true,
          unused: true,
          hoist_funs: true,
          keep_fargs: false,
          hoist_vars: true,
          if_return: true,
          join_vars: true,
          cascade: true,
          side_effects: true,
          warnings: false,
        },
      },
      cssMinifyOptions: {
        level: 2,
      },
    });

Parameters

The minifyAll function accepts the following parameters:

| Parameter | Type | Default | Description | | ------------- | ------ | ------- | -------------------------------------------------------------------------------------------- | | contentPath | string | - | The path to the directory containing the files to be minified. This is a required parameter. | | options | object | {} | An object containing options for minification, Babel, and logging. |

Options

The options object can have the following properties:

| Property | Type | Default | Description | | ------------------ | ----------------- | ------- | ------------------------------------------------------------------------------------------ | | excludeFolder | string | '' | The name of a folder to exclude from minification. | | useBabel | boolean | object | false | If true, enables Babel with default settings. If an object, specifies Babel options. | | useLog | boolean | object | true | If true, enables logging with default settings. If an object, specifies logging options. | | jsMinifyOptions | object | {} | Options for JavaScript minification (passed to UglifyJS). | | cssMinifyOptions | object | {} | Options for CSS minification (passed to CleanCSS). |

Babel Options

When useBabel is an object, it can have the following properties:

| Property | Type | Description | | ------------------------------------- | --------------------------- | --------------------------------------------------------------------------------------------------------- | | targets | string | object | Specifies the target environments. | | modules | string | false | Enables transformation of ES6 module syntax to another module type. | | useBuiltIns | 'usage' | 'entry' | false | Configures how babel-preset-env handles polyfills. | | corejs | number | object | Specifies the core-js version. | | ... (other @babel/preset-env options) | Various | Refer to @babel/preset-env documentation for more options. |

Log Options

When useLog is an object, it can have the following properties:

| Property | Type | Default | Description | | --------------- | ------- | -------------- | --------------------------------------------------------------------- | | logDir | string | 'logs' | Specifies the directory for log files. | | retentionDays | number | 30 | Number of days to retain log files. | | logLevel | string | 'info' | Specifies the level of logging (e.g., 'info', 'warn', 'error'). | | dateFormat | string | 'YYYY-MM-DD' | Format for the date in log entries. | | timeZone | string | 'UTC' | Time zone for timestamps in log entries. | | logToConsole | boolean | true | Determines if logs should also be output to the console. | | logToFile | boolean | true | Determines if logs should be written to a file. |

Minification Options

JavaScript Minification Options

The jsMinifyOptions object is passed directly to UglifyJS. For a full list of available options, please refer to the UglifyJS documentation.

Some commonly used options include:

  • compress: An object specifying compression options.
  • mangle: Controls name mangling. Can be a boolean or an object with more specific options.
  • output: An object controlling the output format.

CSS Minification Options

The cssMinifyOptions object is passed directly to Clean-CSS. For a full list of available options, please refer to the Clean-CSS documentation.

Some commonly used options include:

  • level: Optimization level (0, 1, or 2).
  • compatibility: Browser compatibility (e.g., 'ie7', '*').
  • format: Output formatting options.

Changelog

See CHANGELOG.md for details on each release.

Changelog

License

MIT. See LICENSE.md for details.