Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 26 additions & 7 deletions .storybook/main.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
const { resolve } = require('path');
const { resolve, join } = require('path');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const { twingLoader, valLoader, alias } = require('../twing/webpack-options');
const {
twingLoader,
valLoader,
alias: twingAlias,
} = require('../twing/webpack-options');

module.exports = {
// We load the welcome story separately so it will be the first sidebar item.
Expand All @@ -20,11 +24,11 @@ module.exports = {
const isDev = config.mode === 'development';
// Remove default SVG processing from default config.
// @see https://github.com/storybookjs/storybook/issues/5708#issuecomment-515384927
config.module.rules = config.module.rules.map((data) => {
if (/svg\|/.test(String(data.test))) {
data.test = /\.(ico|jpg|jpeg|png|gif|eot|otf|webp|ttf|woff|woff2|cur|ani)(\?.*)?$/;
config.module.rules = config.module.rules.map((rule) => {
if (/svg\|/.test(String(rule.test))) {
rule.test = /\.(ico|jpg|jpeg|png|gif|eot|otf|webp|ttf|woff|woff2|cur|ani)(\?.*)?$/;
}
return data;
return rule;
});

/**
Expand Down Expand Up @@ -91,11 +95,26 @@ module.exports = {
{
// Optimize and process SVGs as React elements for use in documentation
test: /\.svg$/,
issuer: {
// If we do `url('___.svg')` in a CSS file, we don't want a react component to get inlined
exclude: [/.css$/, /.scss$/],
},
use: '@svgr/webpack',
},
{
test: /\.svg$/,
issuer: {
// If we do `url('___.svg')` in a CSS file, we don't want a react component to get inlined
include: [/.css$/, /.scss$/],
},
use: 'file-loader',
}
);

Object.assign(config.resolve.alias, alias);
Object.assign(config.resolve.alias, twingAlias);
// Allow resolving `static/*` paths so relative paths don't have to be used
// This is used for url() paths in CSS
config.resolve.alias['static'] = join(__dirname, '..', 'static');

config.plugins.push(new MiniCssExtractPlugin());

Expand Down
Loading