Skip to content

Instantly share code, notes, and snippets.

@eliperelman
Last active March 11, 2022 11:54
Show Gist options
  • Save eliperelman/ea82a51c8f9587625c7c472b537f2abb to your computer and use it in GitHub Desktop.
Save eliperelman/ea82a51c8f9587625c7c472b537f2abb to your computer and use it in GitHub Desktop.
SVG preset for Neutrino
// jest.config.js
const neutrino = require('neutrino');
process.env.NODE_ENV = process.env.NODE_ENV || 'test';
module.exports = neutrino().customJest();
module.exports = neutrino => {
neutrino.config.resolve.extensions.add('.svg')
const test = neutrino.config.module
.rule('image')
.get('test')
.toString()
.replace('|svg', '')
neutrino.config.module.rule('image').test(test)
neutrino.config.module
.rule('svg')
.test(/\.svg$/)
.use('webpack')
.loader('@svgr/webpack')
.options({ svgAttributes: { role: 'img' }, titleProp: true })
.end()
.use('file')
.loader('file-loader')
neutrino.register('customJest', neutrino => {
const jestConfig = neutrino().jest();
// modify jestConfig.moduleNameMapper
return jestConfig;
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment