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

cssnano-preset-advanced

Package Overview
Dependencies
Maintainers
7
Versions
80
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cssnano-preset-advanced - npm Package Compare versions

Comparing version 6.0.5 to 6.1.0

types/index.d.ts.map

13

package.json
{
"name": "cssnano-preset-advanced",
"version": "6.0.5",
"version": "6.1.0",
"main": "src/index.js",

@@ -15,7 +15,8 @@ "types": "types/index.d.ts",

"autoprefixer": "^10.4.17",
"cssnano-preset-default": "^6.0.5",
"postcss-discard-unused": "^6.0.3",
"postcss-merge-idents": "^6.0.2",
"postcss-reduce-idents": "^6.0.2",
"postcss-zindex": "^6.0.1"
"browserslist": "^4.23.0",
"cssnano-preset-default": "^6.1.0",
"postcss-discard-unused": "^6.0.4",
"postcss-merge-idents": "^6.0.3",
"postcss-reduce-idents": "^6.0.3",
"postcss-zindex": "^6.0.2"
},

@@ -22,0 +23,0 @@ "author": {

@@ -9,34 +9,94 @@ 'use strict';

/** @typedef {
{autoprefixer?: autoprefixer.Options,
discardUnused?: false | import('postcss-discard-unused').Options & { exclude?: true},
mergeIdents?: false | { exclude?: true},
reduceIdents?:false | import('postcss-reduce-idents').Options & { exclude?: true},
zindex?: false | import('postcss-zindex').Options & { exclude?: true},
}} AdvancedOptions */
/** @typedef {import('cssnano-preset-default').Options & AdvancedOptions} Options */
/**
* @template {object | void} [OptionsExtends=void]
* @typedef {false | OptionsExtends & {exclude?: true}} SimpleOptions
*/
/** @type {Options} */
const defaultOpts = {
autoprefixer: {
add: false,
},
};
/**
* @typedef {object} AdvancedOptions
* @property {autoprefixer.Options} [autoprefixer]
* @property {SimpleOptions<import('postcss-discard-unused').Options>} [discardUnused]
* @property {SimpleOptions} [mergeIdents]
* @property {SimpleOptions<import('postcss-reduce-idents').Options>} [reduceIdents]
* @property {SimpleOptions<import('postcss-zindex').Options>} [zindex]
*/
function advancedPreset(opts = {}) {
const options = Object.assign({}, defaultOpts, opts);
/**
* @typedef {defaultPreset.AutoprefixerOptions} AutoprefixerOptions
* @typedef {defaultPreset.BrowserslistOptions} BrowserslistOptions
* @typedef {defaultPreset.Options & AdvancedOptions} Options
*/
/**
* @param {[import('postcss').PluginCreator<any>, keyof AdvancedOptions][]} plugins
* @param {Parameters<typeof advancedPreset>[0]} opts
* @returns {ReturnType<typeof advancedPreset>["plugins"]}
*/
function configurePlugins(plugins, opts = {}) {
const { overrideBrowserslist, stats, env, path } = opts;
/** @type {[import('postcss').PluginCreator<any>, boolean | Record<string, any> | undefined][]} */
const plugins = [
...defaultPreset(options).plugins,
[autoprefixer, options.autoprefixer],
[postcssDiscardUnused, options.discardUnused],
[postcssMergeIdents, options.mergeIdents],
[postcssReduceIdents, options.reduceIdents],
[postcssZindex, options.zindex],
];
// Shared Autoprefixer + Browserslist options
const sharedProps = {
overrideBrowserslist,
stats,
env,
path,
};
return { plugins };
/**
* @type {AdvancedOptions}
*/
const defaults = {
autoprefixer: {
...sharedProps,
add: false,
// Skip unsupported Browserslist "my stats" strings etc
// https://github.com/browserslist/browserslist/pull/237
stats:
typeof sharedProps.stats !== 'string'
? sharedProps.stats // Autoprefixer supports stats object only
: undefined,
},
};
// Merge option properties for each plugin
return plugins.map(([plugin, opt]) => {
const defaultProps = defaults[opt] ?? {};
const presetProps = opts[opt] ?? {};
return [
plugin,
presetProps !== false
? { ...defaultProps, ...presetProps }
: { exclude: true },
];
});
}
/**
* Advanced optimisations for cssnano; may or may not break your CSS!
*
* @param {Options & AutoprefixerOptions & BrowserslistOptions} opts
* @returns {{ plugins: [import('postcss').PluginCreator<any>, Options[keyof Options]][] }}
*/
function advancedPreset(opts = {}) {
const { plugins: pluginsDefault } = defaultPreset(opts);
return {
plugins: [
...pluginsDefault,
...configurePlugins(
[
[autoprefixer, 'autoprefixer'],
[postcssDiscardUnused, 'discardUnused'],
[postcssMergeIdents, 'mergeIdents'],
[postcssReduceIdents, 'reduceIdents'],
[postcssZindex, 'zindex'],
],
opts
),
],
};
}
module.exports = advancedPreset;
export = advancedPreset;
declare function advancedPreset(opts?: {}): {
plugins: [import("postcss").PluginCreator<any>, boolean | Record<string, any> | undefined][];
/**
* Advanced optimisations for cssnano; may or may not break your CSS!
*
* @param {Options & AutoprefixerOptions & BrowserslistOptions} opts
* @returns {{ plugins: [import('postcss').PluginCreator<any>, Options[keyof Options]][] }}
*/
declare function advancedPreset(opts?: Options & AutoprefixerOptions & BrowserslistOptions): {
plugins: [import('postcss').PluginCreator<any>, Options[keyof Options]][];
};
declare namespace advancedPreset {
export { AdvancedOptions, Options };
export { SimpleOptions, AdvancedOptions, AutoprefixerOptions, BrowserslistOptions, Options };
}
type Options = defaultPreset.Options & AdvancedOptions;
type AutoprefixerOptions = defaultPreset.AutoprefixerOptions;
type BrowserslistOptions = defaultPreset.BrowserslistOptions;
type SimpleOptions<OptionsExtends extends void | object = void> = false | (OptionsExtends & {
exclude?: true;
});
type AdvancedOptions = {
autoprefixer?: autoprefixer.Options;
discardUnused?: false | import('postcss-discard-unused').Options & {
exclude?: true;
};
mergeIdents?: false | {
exclude?: true;
};
reduceIdents?: false | import('postcss-reduce-idents').Options & {
exclude?: true;
};
zindex?: false | import('postcss-zindex').Options & {
exclude?: true;
};
autoprefixer?: autoprefixer.Options | undefined;
discardUnused?: SimpleOptions<postcssDiscardUnused.Options> | undefined;
mergeIdents?: SimpleOptions<void> | undefined;
reduceIdents?: SimpleOptions<postcssReduceIdents.Options> | undefined;
zindex?: SimpleOptions<postcssZindex.Options> | undefined;
};
type Options = import('cssnano-preset-default').Options & AdvancedOptions;
import defaultPreset = require("cssnano-preset-default");
import autoprefixer = require("autoprefixer");
import postcssDiscardUnused = require("postcss-discard-unused");
import postcssReduceIdents = require("postcss-reduce-idents");
import postcssZindex = require("postcss-zindex");
//# sourceMappingURL=index.d.ts.map
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