clean-css-loader
Advanced tools
Comparing version
13
index.js
@@ -1,6 +0,5 @@ | ||
var loaderUtils = require('loader-utils'); | ||
var CleanCSS = require('clean-css'); | ||
module.exports = function (css, map) { | ||
module.exports = function(css, map) { | ||
@@ -12,7 +11,7 @@ var opti = this.options.module; | ||
new CleanCSS(cleanCssOpti).minify(css, function (err, minified) { | ||
if ( err ) { | ||
new CleanCSS(cleanCssOpti).minify(css, function(err, minified) { | ||
if (err) { | ||
if (Array.isArray(err) && (err[0] != null)) { | ||
return callback(err[0]); | ||
}else{ | ||
} else { | ||
return callback(err); | ||
@@ -23,3 +22,3 @@ } | ||
if (((ref = minified.warnings) != null ? ref.lenght : void 0) !== 0) { | ||
ref.forEach(function (msg) { | ||
ref.forEach(function(msg) { | ||
loader.emitWarning(msg.toString()); | ||
@@ -32,2 +31,2 @@ }); | ||
}; | ||
}; |
{ | ||
"name": "clean-css-loader", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"description": "CleanCSS webpack loader", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"repository": { | ||
@@ -27,5 +24,4 @@ "type": "git", | ||
"dependencies": { | ||
"clean-css": "^3.4.9", | ||
"loader-utils": "^0.2.12" | ||
"clean-css": "^4.0.1" | ||
} | ||
} |
@@ -0,1 +1,11 @@ | ||
<div align="center"> | ||
<img src="https://cdn.rawgit.com/jakubpawlowicz/clean-css/master/logo.v2.svg" alt="clean-css logo" width="525px"/> | ||
<br> | ||
<a href="https://github.com/webpack/webpack"> | ||
<img width="200" height="200" | ||
src="https://webpack.js.org/assets/icon-square-big.svg"> | ||
</a> | ||
</div> | ||
A [clean-css](https://github.com/jakubpawlowicz/clean-css) loader for [webpack](https://github.com/webpack/webpack). | ||
@@ -6,5 +16,84 @@ | ||
**Example config:** | ||
<h2 align="center">Install</h2> | ||
```bash | ||
npm install --save-dev clean-css-loader | ||
``` | ||
<em>or</em> | ||
```bash | ||
yarn add clean-css-loader --dev | ||
``` | ||
<h2 align="center">Usage</h2> | ||
Use the loader either via your webpack config, CLI or inline. | ||
### Via webpack config (recommended) | ||
**webpack.config.js** | ||
```js | ||
const production = false; | ||
let css_arr_use = [ 'style-loader', 'css-loader' ]; | ||
if(production){ | ||
css_arr_use.push('clean-css-loader'); | ||
// or | ||
css_arr_use.push({ | ||
loader: 'clean-css-loader', | ||
options: { | ||
compatibility: 'ie9', | ||
level: 2, | ||
inline: ['remote'] | ||
} | ||
}); | ||
} | ||
module.exports = { | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.css$/, | ||
use: css_arr_use | ||
} | ||
] | ||
} | ||
} | ||
``` | ||
**In your application** | ||
```js | ||
import css_min from 'style.css'; | ||
``` | ||
### CLI | ||
```bash | ||
webpack --module-bind 'css=style-loader!css-loader!clean-css-loader' | ||
``` | ||
**In your application** | ||
```js | ||
import css_min from 'style.css'; | ||
``` | ||
### Inline | ||
**In your application** | ||
```js | ||
import css_min from 'style-loader!css-loader!clean-css-loader!./style.css'; | ||
``` | ||
<h2 align="center">Options</h2> | ||
More option: [https://github.com/jakubpawlowicz/clean-css#constructor-options](https://github.com/jakubpawlowicz/clean-css#constructor-options) | ||
**Example config (for webpack 1.x):** | ||
```js | ||
... | ||
@@ -21,3 +110,3 @@ module: { | ||
} | ||
... | ||
//... | ||
] | ||
@@ -30,4 +119,2 @@ // Example Set options (Key "clean-css" or cleancss or CleanCSS): | ||
} | ||
``` | ||
More option: [https://github.com/jakubpawlowicz/clean-css#how-to-use-clean-css-api](https://github.com/jakubpawlowicz/clean-css#how-to-use-clean-css-api) | ||
``` |
Sorry, the diff of this file is not supported yet
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
3487
53.14%1
-50%1
-50%117
277.42%23
-8%+ Added
+ Added
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
Updated