Skip to content

Commit

Permalink
Merge pull request #13607 from storybookjs/13593-babel-loader-from-core
Browse files Browse the repository at this point in the history
Addon-docs: Resolve babel-loader from storybook/core
  • Loading branch information
shilman authored Jan 11, 2021
2 parents 92b459d + 7eef150 commit e9ef268
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions addons/docs/src/frameworks/common/preset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ import remarkExternalLinks from 'remark-external-links';
// @ts-ignore
import createCompiler from '../../mdx/mdx-compiler-plugin';

const resolvedBabelLoader = require.resolve('babel-loader', {
paths: [require.resolve('@storybook/core')],
});

// for frameworks that are not working with react, we need to configure
// the jsx to transpile mdx, for now there will be a flag for that
// for more complex solutions we can find alone that we need to add '@babel/plugin-transform-react-jsx'
Expand Down Expand Up @@ -66,7 +70,7 @@ export function webpack(webpackConfig: any = {}, options: any = {}) {
test: /\.md$/,
use: [
{
loader: require.resolve('babel-loader'),
loader: resolvedBabelLoader,
options: createBabelOptions({ babelOptions, mdxBabelOptions, configureJSX }),
},
{
Expand All @@ -89,7 +93,7 @@ export function webpack(webpackConfig: any = {}, options: any = {}) {
include: new RegExp(`node_modules\\${path.sep}acorn-jsx`),
use: [
{
loader: require.resolve('babel-loader'),
loader: resolvedBabelLoader,
options: {
presets: [[require.resolve('@babel/preset-env'), { modules: 'commonjs' }]],
},
Expand All @@ -100,7 +104,7 @@ export function webpack(webpackConfig: any = {}, options: any = {}) {
test: /\.(stories|story)\.mdx$/,
use: [
{
loader: require.resolve('babel-loader'),
loader: resolvedBabelLoader,
options: createBabelOptions({ babelOptions, mdxBabelOptions, configureJSX }),
},
{
Expand All @@ -117,7 +121,7 @@ export function webpack(webpackConfig: any = {}, options: any = {}) {
exclude: /\.(stories|story)\.mdx$/,
use: [
{
loader: require.resolve('babel-loader'),
loader: resolvedBabelLoader,
options: createBabelOptions({ babelOptions, mdxBabelOptions, configureJSX }),
},
{
Expand Down

0 comments on commit e9ef268

Please sign in to comment.