Skip to content

Commit

Permalink
chore: simplify configs
Browse files Browse the repository at this point in the history
  • Loading branch information
satazor committed Jul 19, 2018
1 parent 4736f2d commit c1c15b5
Show file tree
Hide file tree
Showing 6 changed files with 5,549 additions and 3,010 deletions.
2 changes: 0 additions & 2 deletions .eslintignore

This file was deleted.

1 change: 1 addition & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"eslint-config-moxy/es8",
"eslint-config-moxy/addons/babel-parser",
"eslint-config-moxy/addons/browser",
"eslint-config-moxy/addons/node",
"eslint-config-moxy/addons/object-spread",
"eslint-config-moxy/addons/es6-modules",
"eslint-config-moxy/addons/react",
Expand Down
54 changes: 11 additions & 43 deletions .storybook/webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
const path = require('path');
const SvgStorePlugin = require('external-svg-sprite-loader/lib/SvgStorePlugin');

module.exports = (storybookBaseConfig, configType) => {
module.exports = (config) => {
// CSS files loader for node_modules
storybookBaseConfig.module.rules.push({
config.module.rules.push({
test: /\.css$/,
include: path.join(__dirname, '../node_modules'),
loader: [
Expand All @@ -12,18 +12,12 @@ module.exports = (storybookBaseConfig, configType) => {
],
});

// CSS files loader which enables the use of postcss
storybookBaseConfig.module.rules.push({
// Enable CSS modules and PostCSS
config.module.rules.push({
test: /\.css$/,
exclude: path.join(__dirname, '../node_modules'),
loader: [
{
// Extract CSS files if we are not in development mode
loader: 'style-loader',
options: {
convertToAbsoluteUrls: true,
},
},
'style-loader',
{
loader: 'css-loader',
options: {
Expand All @@ -49,14 +43,13 @@ module.exports = (storybookBaseConfig, configType) => {
// Load SVG files and create an external sprite
// While this has a lot of advantages such as not blocking the initial load,
// it might not workout for every SVG, see: https:/moxystudio/react-with-moxy/issues/6
storybookBaseConfig.module.rules.push({
config.module.rules.push({
test: /\.svg$/,
exclude: [/\.inline\.svg$/, path.join(__dirname, '../src/media/fonts')],
use: [
{
loader: 'external-svg-sprite-loader',
options: {
name: 'images/svg-sprite.svg',
name: 'static/media/svg-sprite.svg',
},
},
// Uniquify classnames and ids so that if svgxuse injects the sprite into the body,
Expand All @@ -69,45 +62,20 @@ module.exports = (storybookBaseConfig, configType) => {
},
],
});
storybookBaseConfig.plugins.push(new SvgStorePlugin());

// Support inline svgs, see explanation above
storybookBaseConfig.module.rules.push({
test: /\.inline\.svg$/,
use: [
'raw-loader',
{
loader: 'svgo-loader',
options: {
plugins: [
{ removeTitle: true },
{ removeDimensions: true },
{ cleanupIDs: false },
],
},
},
// Uniquify classnames and ids so they don't conflict with eachother
{
loader: 'svg-css-modules-loader',
options: {
transformId: true,
},
},
],
});
config.plugins.push(new SvgStorePlugin());

// Support web fonts
storybookBaseConfig.module.rules.push({
config.module.rules.push({
test: /\.(woff2|woff)$/,
use: [
{
loader: 'file-loader',
options: {
name: 'fonts/[name].[ext]',
name: 'static/media/[name].[ext]',
},
},
],
});

return storybookBaseConfig;
return config;
};
1 change: 0 additions & 1 deletion .stylelintignore

This file was deleted.

Loading

0 comments on commit c1c15b5

Please sign in to comment.