Skip to content

Commit

Permalink
Allow setting inlineImageLimit value to 0
Browse files Browse the repository at this point in the history
`0` being falsy, the previous default parameter logic was overwriting the value. This disallowed user to disable image inlining.
  • Loading branch information
SBoudrias committed Sep 28, 2018
1 parent fa837b5 commit bf70e81
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,23 @@ module.exports = (nextConfig = {}) => {
return Object.assign({}, nextConfig, {
webpack(config, options) {
const { isServer } = options;
nextConfig = Object.assign({ inlineImageLimit: 8192, assetPrefix: "" }, nextConfig);

if (!options.defaultLoaders) {
throw new Error(
'This plugin is not compatible with Next.js versions below 5.0.0 https://err.sh/next-plugins/upgrade'
)
}

const assetPrefix = nextConfig.assetPrefix || "";
const limit = nextConfig.inlineImageLimit || 8192;

config.module.rules.push({
test: /\.(jpe?g|png|svg|gif|ico)$/,
use: [
{
loader: "url-loader",
options: {
limit,
limit: nextConfig.inlineImageLimit,
fallback: "file-loader",
publicPath: `${assetPrefix}/_next/static/images/`,
publicPath: `${nextConfig.assetPrefix}/_next/static/images/`,
outputPath: `${isServer ? "../" : ""}static/images/`,
name: "[name]-[hash].[ext]"
}
Expand Down

0 comments on commit bf70e81

Please sign in to comment.