diff --git a/types/optimize-css-assets-webpack-plugin/index.d.ts b/types/optimize-css-assets-webpack-plugin/index.d.ts index d79c14e809..1a55346d3b 100644 --- a/types/optimize-css-assets-webpack-plugin/index.d.ts +++ b/types/optimize-css-assets-webpack-plugin/index.d.ts @@ -1,6 +1,7 @@ -// Type definitions for optimize-css-assets-webpack-plugin 1.3 +// Type definitions for optimize-css-assets-webpack-plugin 5.0 // Project: http://github.com/nmfr/optimize-css-assets-webpack-plugin // Definitions by: Armando Meziat +// Spencer Miskoviak // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 @@ -9,14 +10,47 @@ import { Plugin } from 'webpack'; export = OptimizeCssAssetsPlugin; declare namespace OptimizeCssAssetsPlugin { - interface Options { - assetNameRegExp?: RegExp; - cssProcessor?: any; - cssProcessorOptions?: any; - canPrint?: boolean; - } + interface Options { + /** + * A regular expression that indicates the names of the assets that should + * be optimized \ minimized. The regular expression provided is run against + * the filenames of the files exported by the `ExtractTextPlugin` instances + * in your configuration, not the filenames of your source CSS files + * + * @default /\.css$/g + */ + assetNameRegExp?: RegExp; + /** + * The CSS processor used to optimize \ minimize the CSS. This should be a + * function that follows `cssnano.process` interface (receives a CSS and + * options parameters and returns a Promise). + * + * @default cssnano + */ + cssProcessor?: { + proccess: (css: string, options?: object) => PromiseLike; + }; + /** + * The options passed to the `cssProcessor`. + * + * @default {} + */ + cssProcessorOptions?: object; + /** + * The plugin options passed to the `cssProcessor`. + * + * @default {} + */ + cssProcessorPluginOptions?: object; + /** + * A boolean indicating if the plugin can print messages to the console. + * + * @default true + */ + canPrint?: boolean; + } } declare class OptimizeCssAssetsPlugin extends Plugin { - constructor(options?: OptimizeCssAssetsPlugin.Options); + constructor(options?: OptimizeCssAssetsPlugin.Options); } diff --git a/types/optimize-css-assets-webpack-plugin/optimize-css-assets-webpack-plugin-tests.ts b/types/optimize-css-assets-webpack-plugin/optimize-css-assets-webpack-plugin-tests.ts index 0dd1531313..55da8da2bd 100644 --- a/types/optimize-css-assets-webpack-plugin/optimize-css-assets-webpack-plugin-tests.ts +++ b/types/optimize-css-assets-webpack-plugin/optimize-css-assets-webpack-plugin-tests.ts @@ -1,6 +1,24 @@ -import OptimizeCssAssets = require('optimize-css-assets-webpack-plugin'); +import webpack = require('webpack'); +import OptimizeCssAssetsPlugin = require('optimize-css-assets-webpack-plugin'); -const ocap: OptimizeCssAssets = new OptimizeCssAssets({ - assetNameRegExp: /\.min\.css$/, - canPrint: true -}); +let configuration: webpack.Configuration; + +configuration = { + plugins: [new OptimizeCssAssetsPlugin()], +}; + +configuration = { + plugins: [ + new OptimizeCssAssetsPlugin({ + assetNameRegExp: /\.min\.css$/, + cssProcessor: require('cssnano'), + cssProcessorOptions: { + map: false, + }, + cssProcessorPluginOptions: { + preset: ['default', { discardComments: { removeAll: true } }], + }, + canPrint: true, + }), + ], +};