Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove minimize option #741

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 0 additions & 19 deletions README.md
Expand Up @@ -100,7 +100,6 @@ It's useful when you, for instance, need to post process the CSS as a string.
|**[`import`](#import)** |`{Boolean}`|`true`| Enable/Disable @import handling|
|**[`modules`](#modules)**|`{Boolean}`|`false`|Enable/Disable CSS Modules|
|**[`localIdentName`](#localidentname)**|`{String}`|`[hash:base64]`|Configure the generated ident|
|**[`minimize`](#minimize)**|`{Boolean\|Object}`|`false`|Enable/Disable minification|
|**[`sourceMap`](#sourcemap)**|`{Boolean}`|`false`|Enable/Disable Sourcemaps|
|**[`camelCase`](#camelcase)**|`{Boolean\|String}`|`false`|Export Classnames in CamelCase|
|**[`importLoaders`](#importloaders)**|`{Number}`|`0`|Number of loaders applied before CSS loader|
Expand Down Expand Up @@ -342,24 +341,6 @@ You can also specify the absolute path to your custom `getLocalIdent` function t

> ℹ️ For prerendering with extract-text-webpack-plugin you should use `css-loader/locals` instead of `style-loader!css-loader` **in the prerendering bundle**. It doesn't embed CSS but only exports the identifier mappings.

### `minimize`

By default the css-loader minimizes the css if specified by the module system.

In some cases the minification is destructive to the css, so you can provide your own options to the cssnano-based minifier if needed. See [cssnano's documentation](http://cssnano.co/guides/) for more information on the available options.

You can also disable or enforce minification with the `minimize` query parameter.

**webpack.config.js**
```js
{
loader: 'css-loader',
options: {
minimize: true || {/* CSSNano Options */}
}
}
```

### `sourceMap`

To include source maps set the `sourceMap` option.
Expand Down
3 changes: 1 addition & 2 deletions lib/loader.js
Expand Up @@ -43,7 +43,6 @@ module.exports = function(content, map) {
to: loaderUtils.getCurrentRequest(this).split("!").pop(),
query: query,
resolve: resolve,
minimize: this.minimize,
loaderContext: this,
sourceMap: sourceMap
}, function(err, result) {
Expand Down Expand Up @@ -108,7 +107,7 @@ module.exports = function(content, map) {
return "\" + escape(require(" + loaderUtils.stringifyRequest(this, urlRequest) + ")) + \"";
}.bind(this));
}

var exportJs = compileExports(result, importItemMatcher.bind(this), camelCaseKeys);
if (exportJs) {
exportJs = "exports.locals = " + exportJs + ";";
Expand Down
1 change: 0 additions & 1 deletion lib/localsLoader.js
Expand Up @@ -20,7 +20,6 @@ module.exports = function(content) {
processCss(content, null, {
mode: moduleMode ? "local" : "global",
query: query,
minimize: this.minimize,
loaderContext: this,
resolve: resolve
}, function(err, result) {
Expand Down
13 changes: 0 additions & 13 deletions lib/processCss.js
Expand Up @@ -6,7 +6,6 @@ var formatCodeFrame = require("babel-code-frame");
var Tokenizer = require("css-selector-tokenizer");
var postcss = require("postcss");
var loaderUtils = require("loader-utils");
var assign = require("object-assign");
var getLocalIdent = require("./getLocalIdent");

var icssUtils = require('icss-utils');
Expand Down Expand Up @@ -145,8 +144,6 @@ module.exports = function processCss(inputSource, inputMap, options, callback) {
var context = query.context;
var localIdentName = query.localIdentName || "[hash:base64]";
var localIdentRegExp = query.localIdentRegExp;
var forceMinimize = query.minimize;
var minimize = typeof forceMinimize !== "undefined" ? !!forceMinimize : options.minimize;

var customGetLocalIdent = query.getLocalIdent || getLocalIdent;

Expand Down Expand Up @@ -189,16 +186,6 @@ module.exports = function processCss(inputSource, inputMap, options, callback) {
parserPlugin(parserOptions)
]);

if(minimize) {
var cssnano = require("cssnano");
var minimizeOptions = assign({}, query.minimize);
["zindex", "normalizeUrl", "discardUnused", "mergeIdents", "reduceIdents", "autoprefixer"].forEach(function(name) {
if(typeof minimizeOptions[name] === "undefined")
minimizeOptions[name] = false;
});
pipeline.use(cssnano(minimizeOptions));
}

pipeline.process(inputSource, {
// we need a prefix to avoid path rewriting of PostCSS
from: "/css-loader!" + options.from,
Expand Down