Created
May 14, 2020 18:34
-
-
Save FrankFang/1c4a23bce34e757427433edd14adac6c to your computer and use it in GitHub Desktop.
next file loader // see next-images
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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