Skip to content

Commit

Permalink
fix(nx): remove unneeded webpack rules
Browse files Browse the repository at this point in the history
  • Loading branch information
Isaac Mann authored and vsavkin committed Dec 2, 2019
1 parent 53f17d5 commit ae38c8c
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 39 deletions.
8 changes: 3 additions & 5 deletions packages/storybook/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,15 @@
"@storybook/react": "^5.2.5",
"@storybook/web": "^5.2.5",
"@storybook/addon-knobs": "^5.2.5",
"babel-loader": "^7.5.4",
"@babel/core": "^8.0.6"
"babel-loader": "^8.0.6",
"@babel/core": "^7.5.4"
},
"dependencies": {
"@nrwl/cypress": "*",
"core-js": "^3.2.1",
"tree-kill": "1.2.1",
"ts-loader": "5.3.1",
"tsconfig-paths-webpack-plugin": "3.2.0",
"webpack-node-externals": "1.7.2",
"to-string-loader": "^1.1.5",
"html-loader": "^0.5.5"
"webpack-node-externals": "1.7.2"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const rootWebpackConfig = require('<%= offsetFromRoot %>../.storybook/webpack.co
module.exports = async ({ config, mode }) => {
config = await rootWebpackConfig({ config, mode });
<% if(uiFramework === '@storybook/react') { %>
config.resolve.extensions.push('.tsx');
config.module.rules.push({
test: /\.(ts|tsx)$/,
loader: require.resolve('babel-loader'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,37 +4,7 @@ module.exports = async ({ config, mode }) => {
// You can change the configuration based on that.
// 'PRODUCTION' is used when building the static version of storybook.

r = config.module.rules.filter(rule => rule.test != '/\\.css$/');

// Make whatever fine-grained changes you need
r.push({
test: /\.css$/,
use: [
'to-string-loader',
{
loader: 'style-loader'
},
{
loader: 'css-loader',
options: {
sourceMap: true
}
}
]
});

config.module.rules = r;
config.resolve.extensions.push('.tsx');

let scssLoader = config.module.rules.find(i => !!'a.scss'.match(i.test));
if (scssLoader && scssLoader.use) {
scssLoader.use = ['to-string-loader', ...scssLoader.use];
}

let htmlLoader = config.module.rules.find(i => !!'a.html'.match(i.test));
if (htmlLoader) {
htmlLoader.loader = 'html-loader';
}

// Return the altered config
return config;
Expand Down
5 changes: 1 addition & 4 deletions packages/storybook/src/schematics/init/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,7 @@ function checkDependenciesInstalled(): Rule {
{ name: '@storybook/react', version: storybookVersion },
{ name: '@storybook/addon-knobs', version: storybookVersion },
{ name: 'babel-loader', version: babelLoaderVersion },
{ name: '@babel/core', version: babelCoreVersion },
{ name: 'to-string-loader', version: '*' },
{ name: 'html-loader', version: '*' },
{ name: 'css-loader', version: '*' }
{ name: '@babel/core', version: babelCoreVersion }
);
}
if (
Expand Down

0 comments on commit ae38c8c

Please sign in to comment.