Skip to content

Commit

Permalink
Merge pull request #9 from SBoudrias/patch-1
Browse files Browse the repository at this point in the history
Allow setting `inlineImageLimit` value to 0
  • Loading branch information
arefaslani authored Oct 2, 2018
2 parents fa837b5 + bf70e81 commit a97b32a
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 a97b32a

Please sign in to comment.