From 62465d1efcc2dbe19ffe9c167413dc9c4d167ee5 Mon Sep 17 00:00:00 2001 From: webcore-it Date: Tue, 2 Mar 2021 09:32:00 +0100 Subject: [PATCH] Adds aliases to Storybooks webpack config for emotion 10 packages. --- .storybook/main.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/.storybook/main.js b/.storybook/main.js index c266851..385a9b0 100644 --- a/.storybook/main.js +++ b/.storybook/main.js @@ -1,6 +1,28 @@ +const path = require("path"); + +// Location of root node_modules +const modulesDir = path.join(__dirname, '../node_modules'); + +// As long Storybook depends on emotion 10. +const emotion10Aliases = (config) => ({ + ...config, + resolve: { + ...config.resolve, + alias: { + ...config.resolve.alias, + '@emotion/core': path.join(modulesDir, '@emotion/react'), + '@emotion/styled': path.join(modulesDir, '@emotion/styled'), + '@emotion/styled-base': path.join(modulesDir, '@emotion/styled'), + 'emotion-theming': path.join(modulesDir, '@emotion/react'), + }, + }, +}); + + module.exports = { stories: [ '../src/**/*.stories.@(ts|tsx)', ], addons: [], + webpackFinal: emotion10Aliases, };