Skip to content

Commit

Permalink
Make esbuild/webpack work with .storybook/preview.js
Browse files Browse the repository at this point in the history
This js file uses JSX syntax. We have to treat it separately. Including
loader: jsx in the existing loader makes it not work with TypeScript
so split in into two different loaders for JSX/TS/TSX and JS.
  • Loading branch information
kasperg committed Nov 16, 2023
1 parent 8691453 commit 98a2b15
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,20 @@ module.exports = (_env, argv) => {
module: {
rules: [
{
test: /\.(js|jsx|ts|tsx)$/,
test: /\.(jsx|ts|tsx)$/,
loader: "esbuild-loader",
options: {
target: resolveToEsbuildTarget(browserslist())
}
},
{
test: /\.js$/,
loader: "esbuild-loader",
options: {
loader: "jsx",
target: resolveToEsbuildTarget(browserslist())
}
},
// We consume svg files from dpl-design-system package
{
test: /\.svg$/,
Expand Down

0 comments on commit 98a2b15

Please sign in to comment.