Skip to content

Commit

Permalink
fix(configs): restore IE11 compatibility (#640)
Browse files Browse the repository at this point in the history
* fix(configs): try to transpile all node_modules

* fix(configs): transpile Storybook manager

* style(configs): improve the code comments
  • Loading branch information
connor-baer authored Jul 17, 2020
1 parent d982098 commit 183b33a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 14 deletions.
34 changes: 21 additions & 13 deletions .storybook/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,25 @@ module.exports = {
'@storybook/addon-a11y',
'@storybook/addon-viewport',
],
webpack: (config) => {
config.module.rules = config.module.rules.map((rule) => {
// We want to override the rule for `.js` files only.
if (rule.test && rule.test instanceof RegExp && rule.test.test('.js')) {
return {
...rule,
exclude: /node_modules\/(?!(@sumup|acorn-jsx)\/).*/,
};
}
return rule;
});
return config;
},
webpackFinal: transpileModules,
managerWebpack: transpileModules,
};

// Transpile all node_modules under the @sumup/* namespace.
function transpileModules(config) {
config.module.rules = config.module.rules.map((rule) => {
// Modify all rules that apply to story files.
if (
rule.test &&
rule.test instanceof RegExp &&
['.js', '.ts', '.tsx'].some((extension) => rule.test.test(extension))
) {
return {
...rule,
exclude: /node_modules\/(?!(@sumup|acorn-jsx)\/).*/,
};
}
return rule;
});
return config;
}
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
"create:component": "foundry run plop component",
"static-styles": "cross-env BABEL_ENV=static babel-node --extensions '.js,.ts,.tsx' ./scripts/static-styles/cli.js",
"build:docs": "yarn build:storybook && yarn build:stylesheets",
"prebuild:storybook": "yarn test:output",
"build:storybook": "build-storybook -c .storybook -o public -s .storybook/public",
"build:stylesheets": "mkdir -p public/static && yarn static-styles --global --filePath=./public/static/circuit-ui-v1.css",
"lint": "foundry run eslint . --ext .js,.jsx,.ts,.tsx",
Expand Down

0 comments on commit 183b33a

Please sign in to comment.