Skip to content

Instantly share code, notes, and snippets.

@FrankFang
Created May 14, 2020 18:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save FrankFang/1c4a23bce34e757427433edd14adac6c to your computer and use it in GitHub Desktop.
Save FrankFang/1c4a23bce34e757427433edd14adac6c to your computer and use it in GitHub Desktop.
next file loader // see next-images
const isProd = process.env.NODE_ENV === 'production'
module.exports = {
webpack: (config, options) => {
const {isServer} = options
config.module.rules.push({
test: /\.(svg|png|jpe?g|gif)$/i,
use: isServer ? ['ignore-loader'] : [
{
loader: 'file-loader',
options: {
name: isProd ? '[name].[contenthash].[ext]' : '[name].[ext]',
outputPath: 'static/images/',
publicPath: '_next/static/images/'
},
},
],
})
return config
},
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment