Skip to content

Commit

Permalink
build: Remove react-scripts dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
anicholls committed Apr 8, 2020
1 parent 2cdd5a7 commit cb4d967
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 20 deletions.
36 changes: 17 additions & 19 deletions .storybook/webpack.config.js
Expand Up @@ -20,26 +20,24 @@ module.exports = ({config, mode}) => {
},
];

// Exclude all node_modules from babel-loader
config.module.rules
.find(rule => /mjs\|jsx/.test(rule.test.toString()))
.exclude.push(/node_modules/);

// Filter out extraneous rules added by CRA (react-scripts)
// react-scripts automatically adds js/ts matchers for a `src` folder which we don't use so these rules are moot
config.module.rules = config.module.rules.filter(
rule => !/js\|mjs\|jsx\|ts\|tsx/.test(rule.test.toString())
);

// Override CRA postcss presets
config.module.rules.forEach(rule => {
if (rule.test.toString().includes('scss|sass')) {
delete rule.use[2].options.plugins;
config.module.rules.push({
test: /\.scss$/,
use: [
'style-loader',
'css-loader',
'sass-loader',
{
loader: 'postcss-loader',
options: {
sourceMap: true,
config: {
path: postcssConfigPath,
},
},
},
],

rule.use[2].options.config = {
path: postcssConfigPath,
};
}
include: modulesPath,
});

// Add `.ts` and `.tsx` as a resolvable extension.
Expand Down
1 change: 0 additions & 1 deletion package.json
Expand Up @@ -106,7 +106,6 @@
"react-docgen-typescript": "^1.15.0",
"react-docgen-typescript-loader": "^3.3.0",
"react-dom": "16.12.0",
"react-scripts": "^3.4.1",
"replace-in-files": "^2.0.3",
"request": "^2.88.2",
"rimraf": "^2.6.3",
Expand Down

0 comments on commit cb4d967

Please sign in to comment.