Skip to content
This repository has been archived by the owner on Mar 17, 2023. It is now read-only.

Commit

Permalink
add support for webpack 4
Browse files Browse the repository at this point in the history
We currently already have support for webpack4, so I just needed to
add some tests.
  • Loading branch information
Daniel Schmidt committed May 14, 2018
1 parent b30e0fb commit ac03972
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 3 deletions.
8 changes: 5 additions & 3 deletions package.json
Expand Up @@ -12,8 +12,9 @@
"test:webpack1": "npm install -q webpack@1.x && npm run test:clean && webpack --config test/webpack1.config.js",
"test:webpack2": "npm install -q webpack@2.x && npm run test:clean && webpack --config test/webpack2.config.js",
"test:webpack3": "npm install -q webpack@3.x && npm run test:clean && webpack --config test/webpack2.config.js",
"test:webpack4": "npm install -q webpack@4.x webpack-cli && npm run test:clean && webpack --config test/webpack4.config.js",
"test:clean": "rm -rf test/public/assets",
"test": "npm run test:webpack1 && npm run test:webpack2 && npm run test:webpack3"
"test": "npm run test:webpack1 && npm run test:webpack2 && npm run test:webpack3 && npm run test:webpack4"
},
"dependencies": {
"imagemin": "^5.2.2",
Expand All @@ -24,9 +25,10 @@
"imagemin-svgo": "^6.0.0",
"imagemin-webp": "^4.0.0",
"loader-utils": "^1.1.0",
"object-assign": "^4.1.1"
"object-assign": "^4.1.1",
"webpack-cli": "^2.1.3"
},
"devDependencies": {
"file-loader": "^0.10.1"
"file-loader": "^1.1.11"
}
}
77 changes: 77 additions & 0 deletions test/webpack4.config.js
@@ -0,0 +1,77 @@
'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
}
]
},
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 ac03972

Please sign in to comment.