2.2.4 • Published 10 months ago

uglify-js-minify-css-allfiles v2.2.4

Weekly downloads
4
License
MIT
Repository
github
Last release
10 months ago

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:

ParameterTypeDefaultDescription
contentPathstring-The path to the directory containing the files to be minified. This is a required parameter.
optionsobject{}An object containing options for minification, Babel, and logging.

Options

The options object can have the following properties:

PropertyTypeDefaultDescription
excludeFolderstring''The name of a folder to exclude from minification.
useBabelboolean | objectfalseIf true, enables Babel with default settings. If an object, specifies Babel options.
useLogboolean | objecttrueIf true, enables logging with default settings. If an object, specifies logging options.
jsMinifyOptionsobject{}Options for JavaScript minification (passed to UglifyJS).
cssMinifyOptionsobject{}Options for CSS minification (passed to CleanCSS).

Babel Options

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

PropertyTypeDescription
targetsstring | objectSpecifies the target environments.
modulesstring | falseEnables transformation of ES6 module syntax to another module type.
useBuiltIns'usage' | 'entry' | falseConfigures how babel-preset-env handles polyfills.
corejsnumber | objectSpecifies the core-js version.
... (other @babel/preset-env options)VariousRefer to @babel/preset-env documentation for more options.

Log Options

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

PropertyTypeDefaultDescription
logDirstring'logs'Specifies the directory for log files.
retentionDaysnumber30Number of days to retain log files.
logLevelstring'info'Specifies the level of logging (e.g., 'info', 'warn', 'error').
dateFormatstring'YYYY-MM-DD'Format for the date in log entries.
timeZonestring'UTC'Time zone for timestamps in log entries.
logToConsolebooleantrueDetermines if logs should also be output to the console.
logToFilebooleantrueDetermines 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.

2.2.1

10 months ago

2.0.3

10 months ago

2.2.0

10 months ago

2.1.1

10 months ago

2.0.2

10 months ago

2.2.3

10 months ago

2.2.2

10 months ago

2.0.4

10 months ago

2.2.4

10 months ago

2.1.0

10 months ago

2.0.1

10 months ago

2.0.0

10 months ago

1.3.3

1 year ago

1.3.1

2 years ago

1.3.0

2 years ago

1.2.9

3 years ago

1.2.8

4 years ago

1.2.7

4 years ago

1.2.6

4 years ago

1.2.5

4 years ago

1.2.4

4 years ago

1.2.3

4 years ago

1.2.2

5 years ago

1.2.1

5 years ago

1.2.0

5 years ago

1.1.9

5 years ago

1.1.8

5 years ago

1.1.7

5 years ago

1.1.6

5 years ago

1.1.5

5 years ago

1.1.4

5 years ago

1.1.3

5 years ago

1.1.2

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago