import autoprefixer from 'autoprefixer';

export function createDefaultWebpackConfig(storybookBaseConfig) {
  return {
    ...storybookBaseConfig,
    module: {
      ...storybookBaseConfig.module,
      rules: [
        ...storybookBaseConfig.module.rules,
        {
          test: /\.css$/,
          use: [
            require.resolve('style-loader'),
            {
              loader: require.resolve('css-loader'),
              options: {
                importLoaders: 1,
              },
            },
            {
              loader: require.resolve('postcss-loader'),
              options: {
                ident: 'postcss', // https://webpack.js.org/guides/migrating/#complex-options
                postcss: {},
                plugins: () => [
                  require('postcss-flexbugs-fixes'), // eslint-disable-line
                  autoprefixer({
                    flexbox: 'no-2009',
                  }),
                ],
              },
            },
          ],
        },
        {
          test: /\.(svg|ico|jpg|jpeg|png|gif|eot|otf|webp|ttf|woff|woff2)(\?.*)?$/,
          loader: require.resolve('file-loader'),
          query: {
            name: 'static/media/[name].[hash:8].[ext]',
          },
        },
        {
          test: /\.(mp4|webm|wav|mp3|m4a|aac|oga)(\?.*)?$/,
          loader: require.resolve('url-loader'),
          query: {
            limit: 10000,
            name: 'static/media/[name].[hash:8].[ext]',
          },
        },
      ],
    },
  };
}

@@ -35,16 +35,58 @@
 ixer';%0A%0A
+const cssModuleRegex = /%5C.module%5C.css$/;%0A%0A
 export f
@@ -325,24 +325,59 @@
 : /%5C.css$/,%0A
+          exclude: cssModuleRegex,%0A
           us
@@ -1007,16 +1007,16 @@
     %7D),%0A
-
         
@@ -1084,32 +1084,422 @@
    %7D,%0A        %7B%0A
+          test: cssModuleRegex,%0A          loaders: %5B%0A            require.resolve('style-loader'),%0A            %7B%0A              loader: require.resolve('css-loader'),%0A              options: %7B%0A                importLoaders: 1,%0A                modules: true,%0A                localIdentName: '%5Bname%5D__%5Blocal%5D___%5Bhash:base64:5%5D',%0A              %7D,%0A            %7D,%0A          %5D,%0A        %7D,%0A        %7B%0A
           test: 

Support css-modules