Initial commit

This commit is contained in:
Developer
2025-04-21 16:03:20 +02:00
commit 2832896157
22874 changed files with 3092801 additions and 0 deletions

View File

@@ -0,0 +1,4 @@
language: node_js
node_js:
- '4.8'
- stable

View File

@@ -0,0 +1,36 @@
# Changelog
## 2.0.1
Updated dependencies
## 2.0.0
Require Node 4. Support only webpack 2. Switch from jpegtran to mozjpeg.
Switch to `enabled` option instead of detecting `minimize` from UglifyJSPlugin.
## 1.3.1
Updated dependencies
## 1.3.0
Support `?config=otherConfig` to specify advanced options
## 1.2.2
Make sure that the webpack callback is only called once
## 1.2.1
Updated dependencies
## 1.2.0
New: Allow using pngquant plugin via advanced options
Match default `optimizationLevel` 2 in plugin in this loader's defaults
## 1.1.0
New: Allow options in an `imagemin` property on the webpack config

View File

@@ -0,0 +1,22 @@
Copyright (c) 2015 Andy VanWagoner
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.

View File

@@ -0,0 +1,114 @@
# img-loader
[![npm Version][npm-image]][npm]
[![Greenkeeper badge][greenkeeper-image]][greenkeeper]
[![Build Status][build-image]][build]
[![JS Standard Style][style-image]][style]
[![MIT License][license-image]][LICENSE]
Image minimizing loader for webpack 2, meant to be used with [url-loader](https://github.com/webpack/url-loader), [file-loader](https://github.com/webpack/file-loader), or [raw-loader](https://github.com/webpack/raw-loader)
> Minify PNG, JPEG, GIF and SVG images with [imagemin](https://github.com/imagemin/imagemin)
*Issues with the minimized output should be reported [to imagemin](https://github.com/imagemin/imagemin/issues).*
Comes with the following optimizers:
- [gifsicle](https://github.com/imagemin/imagemin-gifsicle) — *Compress GIF images*
- [mozjpeg](https://github.com/imagemin/imagemin-mozjpeg) — *Compress JPEG images*
- [optipng](https://github.com/imagemin/imagemin-optipng) — *Compress PNG images*
- [pngquant](https://github.com/imagemin/imagemin-pngquant) — *Compress PNG images*
- [svgo](https://github.com/imagemin/imagemin-svgo) — *Compress SVG images*
## Install
```sh
$ npm install img-loader --save-dev
```
## Usage
[Documentation: Using loaders](http://webpack.github.io/docs/using-loaders.html)
```javascript
module: {
rules: [
{
test: /\.(jpe?g|png|gif|svg)$/i,
use: [
'url-loader?limit=10000',
'img-loader'
]
}
]
}
```
The default minification includes: `gifsicle`, `mozjpeg`, `optipng`, & `svgo`. Each with their default settings.
`pngquant` can be enabled by configuring it in the options.
### Options
Options can also be passed by specifying properties matching each optimizer in your rule options. `false` or `null` can be used to disable one of the default optimizers.
For more details on each plugin's options, see their documentation on [Github](https://github.com/imagemin).
``` javascript
{
module: {
rules: [
{
test: /\.(jpe?g|png|gif|svg)$/i,
use: [
'url-loader?limit=10000',
{
loader: 'img-loader',
options: {
enabled: process.env.NODE_ENV === 'production',
gifsicle: {
interlaced: false
},
mozjpeg: {
progressive: true,
arithmetic: false
},
optipng: false, // disabled
pngquant: {
floyd: 0.5,
speed: 2
},
svgo: {
plugins: [
{ removeTitle: true },
{ convertPathData: false }
]
}
}
}
]
}
]
}
}
```
## License
This software is free to use under the MIT license. See the [LICENSE-MIT file][LICENSE] for license text and copyright information.
[npm]: https://www.npmjs.org/package/img-loader
[npm-image]: https://img.shields.io/npm/v/img-loader.svg
[greenkeeper-image]: https://badges.greenkeeper.io/thetalecrafter/img-loader.svg
[greenkeeper]: https://greenkeeper.io/
[build]: https://travis-ci.org/thetalecrafter/img-loader
[build-image]: https://img.shields.io/travis/thetalecrafter/img-loader.svg
[style]: https://github.com/feross/standard
[style-image]: https://img.shields.io/badge/code%20style-standard-brightgreen.svg
[license-image]: https://img.shields.io/npm/l/img-loader.svg
[LICENSE]: https://github.com/thetalecrafter/img-loader/blob/master/LICENSE-MIT

View File

@@ -0,0 +1,53 @@
/* eslint-env mocha */
'use strict'
var assert = require('assert')
var Buffer = require('safe-buffer').Buffer
var loader = require('..')
describe('img-loader', () => {
describe('svgo', () => {
it('optimizes svg images by default', (done) => {
var img = Buffer.from('<svg><g><path d="M0 0" /></g></svg>')
var context = {
loader,
async () {
return (error, buffer) => {
if (error) return done(error)
assert.equal(buffer.toString(), '<svg/>')
done()
}
}
}
context.loader(img)
})
it('passes content through when whole loader disabled', () => {
var img = Buffer.from('<svg></svg>')
var context = {
loader,
query: { enabled: false },
async () {
assert.fail('should not call async')
}
}
assert.equal(context.loader(img), img)
})
it('does not optimize when plugin disabled', (done) => {
var img = Buffer.from('<svg></svg>')
var context = {
loader,
query: { svgo: false },
async () {
return (error, buffer) => {
if (error) return done(error)
assert.equal(buffer.toString(), '<svg></svg>')
done()
}
}
}
context.loader(img)
})
})
})

View File

@@ -0,0 +1,48 @@
'use strict'
var imagemin = require('imagemin')
var imageminGifsicle = require('imagemin-gifsicle')
var imageminMozjpeg = require('imagemin-mozjpeg')
var imageminOptipng = require('imagemin-optipng')
var imageminPngquant = require('imagemin-pngquant')
var imageminSvgo = require('imagemin-svgo')
var loaderUtils = require('loader-utils')
var defaults = {
enabled: true,
gifsicle: {},
mozjpeg: {},
optipng: {},
svgo: {}
}
module.exports = function (content) {
this.cacheable && this.cacheable()
var options = Object.assign(
Object.create(defaults),
loaderUtils.getOptions(this)
)
if (!options.enabled) {
return content
}
var use = [
options.gifsicle && imageminGifsicle(options.gifsicle),
options.mozjpeg && imageminMozjpeg(options.mozjpeg),
options.optipng && imageminOptipng(options.optipng),
options.svgo && imageminSvgo(options.svgo),
options.pngquant && imageminPngquant(options.pngquant)
].filter(Boolean)
if (use.length === 0) {
return content
}
var callback = this.async()
imagemin
.buffer(content, { use: use })
.then(function (buffer) { callback(null, buffer) })
.catch(function (error) { callback(error) })
}
module.exports.raw = true

View File

@@ -0,0 +1,70 @@
{
"_from": "img-loader@^2.0.0",
"_id": "img-loader@2.0.1",
"_inBundle": false,
"_integrity": "sha512-cD5D+zzIDvVPyX9nmz6+GL20BfpRUKUEXFur9IPeUC8/LRJT/PQ3YJVyKelIum8R5rCVZXgSFB0ccpsnS4IyAQ==",
"_location": "/img-loader",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "img-loader@^2.0.0",
"name": "img-loader",
"escapedName": "img-loader",
"rawSpec": "^2.0.0",
"saveSpec": null,
"fetchSpec": "^2.0.0"
},
"_requiredBy": [
"/laravel-mix"
],
"_resolved": "https://registry.npmjs.org/img-loader/-/img-loader-2.0.1.tgz",
"_shasum": "de8f80aa5e3222fa1eb4c8c3bc3d41e5d8dd7c78",
"_spec": "img-loader@^2.0.0",
"_where": "D:\\developments\\teaser-inertia\\nova-components\\NovaLeader\\node_modules\\laravel-mix",
"author": {
"name": "Andy VanWagoner",
"email": "thetalecrafter@gmail.com"
},
"bugs": {
"url": "https://github.com/thetalecrafter/img-loader/issues"
},
"bundleDependencies": false,
"dependencies": {
"imagemin": "^5.3.1",
"imagemin-gifsicle": "^5.2.0",
"imagemin-mozjpeg": "^7.0.0",
"imagemin-optipng": "^5.2.0",
"imagemin-pngquant": "^5.0.1",
"imagemin-svgo": "^6.0.0",
"loader-utils": "^1.1.0"
},
"deprecated": false,
"description": "Image minimizing loader for webpack",
"devDependencies": {
"mocha": "^5.0.0",
"safe-buffer": "^5.1.1",
"standard": "^10.0.1"
},
"homepage": "https://github.com/thetalecrafter/img-loader",
"keywords": [
"image",
"imagemin",
"image-loader",
"optimize",
"minify",
"webpack",
"webpack-loader"
],
"license": "MIT",
"name": "img-loader",
"repository": {
"type": "git",
"url": "git+ssh://git@github.com/thetalecrafter/img-loader.git"
},
"scripts": {
"pretest": "standard",
"test": "mocha __tests__/*.spec.js"
},
"version": "2.0.1"
}