forked from tcoopman/image-webpack-loader
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(test): added tests for additional plugin feat
- Loading branch information
1 parent
0d39d46
commit 08dd544
Showing
2 changed files
with
93 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,23 +13,26 @@ | |
"test:webpack2": "npm install -q [email protected] && npm run test:clean && webpack --config test/webpack2.config.js", | ||
"test:webpack3": "npm install -q [email protected] && npm run test:clean && webpack --config test/webpack2.config.js", | ||
"test:webpack4": "npm install -q [email protected] webpack-cli && npm run test:clean && webpack --config test/webpack4.config.js", | ||
"test:webpack-additional": "npm install -q [email protected] [email protected] imagemin-jpegtran && npm run test:clean && webpack --config test/webpack-additional.config.js", | ||
"test:clean": "rimraf test/public/assets", | ||
"test": "npm run test:webpack1 && npm run test:webpack2 && npm run test:webpack3 && npm run test:webpack4" | ||
}, | ||
"dependencies": { | ||
"imagemin": "^5.3.1", | ||
"imagemin-gifsicle": "^5.2.0", | ||
"imagemin-jpegtran": "^6.0.0", | ||
"imagemin-mozjpeg": "^7.0.0", | ||
"imagemin-optipng": "^5.2.1", | ||
"imagemin-pngquant": "^5.1.0", | ||
"imagemin-svgo": "^6.0.0", | ||
"imagemin-webp": "^4.1.0", | ||
"loader-utils": "^1.1.0", | ||
"object-assign": "^4.1.1" | ||
"object-assign": "^4.1.1", | ||
"webpack": "^4.41.2" | ||
}, | ||
"devDependencies": { | ||
"file-loader": "^1.1.11", | ||
"rimraf": "^2.6.2", | ||
"webpack-cli": "^2.1.3" | ||
"webpack-cli": "^3.3.10" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
'use strict'; | ||
var path = require('path'); | ||
var webpack = require('webpack'); | ||
|
||
var assetsPath = path.join(__dirname, 'public/assets'); | ||
|
||
var loaderOptions = { | ||
mozjpeg: { | ||
quality: 65 | ||
}, | ||
pngquant: { | ||
quality: '65-90', | ||
speed: 4 | ||
}, | ||
svgo: { | ||
plugins: [ | ||
{ | ||
removeViewBox: false | ||
}, | ||
{ | ||
removeEmptyAttrs: false | ||
} | ||
] | ||
}, | ||
additionalPlugins: [ | ||
{ | ||
plugin: 'imagemin-jpegtran', | ||
options: { | ||
progressive: true | ||
} | ||
} | ||
], | ||
gifsicle: { | ||
optimizationLevel: 7, | ||
interlaced: false | ||
}, | ||
optipng: { | ||
optimizationLevel: 7, | ||
interlaced: false | ||
}, | ||
webp: { | ||
quality: 75 | ||
} | ||
}; | ||
|
||
var fileLoaderOptions = { | ||
hash: 'sha512', | ||
digest: 'hex', | ||
name: '[hash].[ext]' | ||
}; | ||
|
||
module.exports = [ | ||
{ | ||
mode: 'production', | ||
entry: './test/app.js', | ||
output: { | ||
path: assetsPath, | ||
filename: 'app.[hash].js' | ||
}, | ||
module: { | ||
rules: [ | ||
{ | ||
test: /.*\.(gif|png|jpe?g|svg|webp)$/i, | ||
use: [ | ||
{ | ||
loader: 'file-loader', | ||
options: fileLoaderOptions | ||
}, | ||
{ | ||
loader: require.resolve('../'), | ||
options: loaderOptions | ||
} | ||
] | ||
}, | ||
{ | ||
test: /\.bmp$/i, | ||
use: [ | ||
{ | ||
loader: 'file-loader', | ||
options: fileLoaderOptions | ||
}, | ||
require.resolve('../') // loaderUtils.getOptions() returns null for this one | ||
] | ||
} | ||
] | ||
} | ||
} | ||
]; |