Skip to content

Commit

Permalink
fix: don't crash the ui-kit storybook
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelltoth committed Jul 15, 2020
1 parent 24c2b7b commit 64bc423
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions src/webpack.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,21 @@ module.exports = ({ config }: any) => {
],
});

let svgIconFunc: () => unknown;
try{
const uiKitPath = require.resolve('@stoplight/ui-kit');
svgIconFunc = inliner(path.dirname(uiKitPath)+'/styles/icons', {
// run through SVGO first
optimize: true,
// minimal "uri" encoding is smaller than base64
encodingFormat: 'uri',
});
} catch (e) {
svgIconFunc = () => {
throw e;
};
}

config.module.rules.push({
test: /\.scss$/,
include: [path.resolve(cwd, 'src')],
Expand Down Expand Up @@ -92,12 +107,7 @@ module.exports = ({ config }: any) => {
sassOptions: {
importer: [PackageImporter()],
functions: {
'svg-icon': inliner(path.dirname(require.resolve('@stoplight/ui-kit'))+'/styles/icons', {
// run through SVGO first
optimize: true,
// minimal "uri" encoding is smaller than base64
encodingFormat: 'uri',
}),
'svg-icon': svgIconFunc,
},
}
},
Expand Down

0 comments on commit 64bc423

Please sign in to comment.