Skip to content

Instantly share code, notes, and snippets.

@ivanoats
Last active June 21, 2016 04:56
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 ivanoats/853d0e832faa70e0541166a4027affe7 to your computer and use it in GitHub Desktop.
Save ivanoats/853d0e832faa70e0541166a4027affe7 to your computer and use it in GitHub Desktop.
two versions, one based on README and another based on removing eslint warnings
export function modifyWebpackConfig (config) {
// Object.assign is not picked up as mutation by immutable linter ?!
config.loader('jpg', (cfg) => Object.assign(
cfg,
{
test: /\.jpe?g$|\.gif$|\.png$/i,
loader: 'file-loader?name=images/[name].[ext]',
}
))
return config
}
export function modifyWebpackConfig (config) {
// arrow-body-style rule doesn't recognize that the spread operator needs
// to be in an object literal
// eslint-disable-next-line arrow-body-style
config.loader('jpg', (cfg) => {
return {
...cfg,
test: /\.jpe?g$|\.gif$|\.png$/i,
loader: 'file-loader?name=images/[name].[ext]',
}
})
return config
}
// eslint-disable-next-line immutable/no-mutation,no-unused-vars
exports.modifyWebpackConfig = function (config, env) {
config.loader('jpg', (cfg) => {
// eslint-disable-next-line immutable/no-mutation,no-param-reassign
cfg.test = /\.jpe?g$|\.gif$|\.png$/i
// eslint-disable-next-line immutable/no-mutation,no-param-reassign
cfg.loader = 'file-loader?name=images/[name].[ext]'
return cfg
})
return config
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment