Skip to content

Commit

Permalink
Merge pull request #1 from anikethsaha/test/additional-plugins
Browse files Browse the repository at this point in the history
chore(test): added tests for additional plugin feat
  • Loading branch information
Shawn Corrigan authored Dec 11, 2019
2 parents 0d39d46 + 08dd544 commit be5f209
Show file tree
Hide file tree
Showing 2 changed files with 93 additions and 2 deletions.
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
88 changes: 88 additions & 0 deletions test/webpack-additional.config.js
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
]
}
]
}
}
];

0 comments on commit be5f209

Please sign in to comment.