feat(storybook): Custom .babelrc in Storybook (#10551)
This commit is contained in:
parent
8ed3c7071a
commit
52f824cfe1
@ -307,6 +307,10 @@
|
|||||||
"type": "string",
|
"type": "string",
|
||||||
"description": "Path to storybook preview.js file."
|
"description": "Path to storybook preview.js file."
|
||||||
},
|
},
|
||||||
|
"babelrcPath": {
|
||||||
|
"type": "string",
|
||||||
|
"description": "Path to storybook .babelrc file."
|
||||||
|
},
|
||||||
"srcRoot": {
|
"srcRoot": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"description": "Project source path."
|
"description": "Project source path."
|
||||||
|
|||||||
@ -147,31 +147,36 @@ export const webpack = async (
|
|||||||
'11.0.0'
|
'11.0.0'
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
const babelrc = readJsonFile(
|
try {
|
||||||
joinPathFragments(options.configDir, '../', '.babelrc')
|
const babelrc = readJsonFile(
|
||||||
);
|
options.babelrcPath ||
|
||||||
if (babelrc?.plugins?.includes('@emotion/babel-plugin')) {
|
joinPathFragments(options.configDir, '../', '.babelrc')
|
||||||
resolvedEmotionAliases = {
|
);
|
||||||
resolve: {
|
if (babelrc?.plugins?.includes('@emotion/babel-plugin')) {
|
||||||
alias: {
|
resolvedEmotionAliases = {
|
||||||
'@emotion/core': joinPathFragments(
|
resolve: {
|
||||||
workspaceRoot,
|
alias: {
|
||||||
'node_modules',
|
'@emotion/core': joinPathFragments(
|
||||||
'@emotion/react'
|
workspaceRoot,
|
||||||
),
|
'node_modules',
|
||||||
'@emotion/styled': joinPathFragments(
|
'@emotion/react'
|
||||||
workspaceRoot,
|
),
|
||||||
'node_modules',
|
'@emotion/styled': joinPathFragments(
|
||||||
'@emotion/styled'
|
workspaceRoot,
|
||||||
),
|
'node_modules',
|
||||||
'emotion-theming': joinPathFragments(
|
'@emotion/styled'
|
||||||
workspaceRoot,
|
),
|
||||||
'node_modules',
|
'emotion-theming': joinPathFragments(
|
||||||
'@emotion/react'
|
workspaceRoot,
|
||||||
),
|
'node_modules',
|
||||||
|
'@emotion/react'
|
||||||
|
),
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
};
|
||||||
};
|
}
|
||||||
|
} catch (error) {
|
||||||
|
// silently ignore if the .babelrc doesn't exist
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return mergeWebpack.merge(
|
return mergeWebpack.merge(
|
||||||
|
|||||||
@ -76,6 +76,10 @@
|
|||||||
"type": "string",
|
"type": "string",
|
||||||
"description": "Path to storybook preview.js file."
|
"description": "Path to storybook preview.js file."
|
||||||
},
|
},
|
||||||
|
"babelrcPath": {
|
||||||
|
"type": "string",
|
||||||
|
"description": "Path to storybook .babelrc file."
|
||||||
|
},
|
||||||
"srcRoot": {
|
"srcRoot": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"description": "Project source path."
|
"description": "Project source path."
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user