NMFR/optimize-css-assets-webpack-plugin
소개
CSS 에셋을 최적화하고 압축하는 Webpack 플러그인입니다.
웹 및 앱 개발측정된 스타 증가
- in 24h
- 0
- in 7 days
- 0
- in 15 days
- 0
- in 1 month
- -2
서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.
README.md
OriginalOptimize CSS Assets Webpack Plugin
A Webpack plugin to optimize \ minimize CSS assets.
:warning: For webpack v5 or above please use css-minimizer-webpack-plugin instead.
What does the plugin do?
It will search for CSS assets during the Webpack build and will optimize \ minimize the CSS (by default it uses cssnano but a custom CSS processor can be specified).
Solves extract-text-webpack-plugin CSS duplication problem:
Since extract-text-webpack-plugin only bundles (merges) text chunks, if it's used to bundle CSS, the bundle might have duplicate entries (chunks can be duplicate free but when merged, duplicate CSS can be created).
Installation:
Using npm:
$ npm install --save-dev optimize-css-assets-webpack-plugin
:warning: For webpack v3 or below please use
[email protected]. The[email protected]version and above supports webpack v4.
Configuration:
The plugin can receive the following options (all of them are optional):
assetNameRegExp: 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 theExtractTextPlugininstances in your configuration, not the filenames of your source CSS files. Defaults to/\.css$/gcssProcessor: The CSS processor used to optimize \ minimize the CSS, defaults tocssnano. This should be a function that followscssnano.processinterface (receives a CSS and options parameters and returns a Promise).cssProcessorOptions: The options passed to thecssProcessor, defaults to{}cssProcessorPluginOptions: The plugin options passed to thecssProcessor, defaults to{}canPrint: A boolean indicating if the plugin can print messages to the console, defaults totrue
Example:
var OptimizeCssAssetsPlugin = require('optimize-css-assets-webpack-plugin');
module.exports = {
module: {
rules: [
{
test: /\.css$/,
loader: ExtractTextPlugin.extract('style-loader', 'css-loader')
}
]
},
plugins: [
new ExtractTextPlugin('styles.css'),
new OptimizeCssAssetsPlugin({
assetNameRegExp: /\.optimize\.css$/g,
cssProcessor: require('cssnano'),
cssProcessorPluginOptions: {
preset: ['default', { discardComments: { removeAll: true } }],
},
canPrint: true
})
]
};
License
관련 프로젝트 살펴보기
불러오는 중…