Last active
March 11, 2022 11:54
-
-
Save eliperelman/ea82a51c8f9587625c7c472b537f2abb to your computer and use it in GitHub Desktop.
SVG preset for Neutrino
This file contains 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
// jest.config.js | |
const neutrino = require('neutrino'); | |
process.env.NODE_ENV = process.env.NODE_ENV || 'test'; | |
module.exports = neutrino().customJest(); |
This file contains 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
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