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

Commit

Permalink
Merge pull request #155 from DanielMSchmidt/danielmschmidt/webpack-4-…
Browse files Browse the repository at this point in the history
…support

Ensure support for webpack 4
  • Loading branch information
tcoopman authored May 21, 2018
2 parents b30e0fb + ac03972 commit 84f3122
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 3 deletions.
8 changes: 5 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@
"test:webpack1": "npm install -q [email protected] && npm run test:clean && webpack --config test/webpack1.config.js",
"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: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
Original file line number Diff line number Diff line change
@@ -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 84f3122

Please sign in to comment.