Skip to content

Instantly share code, notes, and snippets.

@fivethreeo
Last active May 18, 2020 22:09
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 fivethreeo/5e0127fa63ab7003efd0f59df3fa61b7 to your computer and use it in GitHub Desktop.
Save fivethreeo/5e0127fa63ab7003efd0f59df3fa61b7 to your computer and use it in GitHub Desktop.
add a webpack module to razzle.config.js
'use strict';
module.exports = {
modify: (defaultConfig, { target, dev }, webpack) => {
const config = Object.assign({}, defaultConfig);
config.module.rules = config.module.rules.reduce((rules, rule) => {
if (rule.exclude &&
rule.loader.indexOf('file-loader') !== -1) {
const { exclude, ...rest } = rule;
rules.push({ ...rest, ...{
exclude: exclude.concat([/\.svg$/])
}});
}
else {
rules.push(rule);
}
return rules;
}, []);
config.module.rules.push({
test: /\.svg$/,
use: [
{
loader: require.resolve('babel-loader'),
},
{
loader: require.resolve('react-svg-loader'),
options: {
jsx: true // true outputs JSX tags
}
}
]
});
return config;
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment