Skip to content

What is the point of this package? #29

@fregante

Description

@fregante

I was looking for an alternative to my current setup (a handful of lines) and landed on this add-on.

export async function webpackFinal(config) {
  config.module.rules.push({
    test: /\.s?css$/,
    use: [
      "style-loader",
      "css-loader",
      "sass-loader",
    ],
  });
}

I ran it and it generated 50 lines of config:

export const addons = [
  "@storybook/addon-styling-webpack",
  {
    name: "@storybook/addon-styling-webpack",

    options: {
      rules: [
        {
          test: /\.css$/,
          sideEffects: true,
          use: [
            require.resolve("style-loader"),
            {
              loader: require.resolve("css-loader"),
              options: {
                // Want to add more CSS Modules options? Read more here: https://github.com/webpack-contrib/css-loader#modules
                modules: {
                  auto: true,
                },
              },
            },
          ],
        },
        {
          test: /\.s[ac]ss$/,
          sideEffects: true,
          use: [
            require.resolve("style-loader"),
            {
              loader: require.resolve("css-loader"),
              options: {
                // Want to add more CSS Modules options? Read more here: https://github.com/webpack-contrib/css-loader#modules
                modules: {
                  auto: true,
                },
                importLoaders: 2,
              },
            },
            require.resolve("resolve-url-loader"),
            {
              loader: require.resolve("sass-loader"),
              options: {
                // Want to add more Sass options? Read more here: https://webpack.js.org/loaders/sass-loader/#options
                implementation: require.resolve("sass"),
                sourceMap: true,
                sassOptions: {},
              },
            },
          ],
        },
      ],
    },
  },
];

Why is this needed? What is addon-styling-webpack doing other than generating extra config? I'd assume that an extra package would reduce config.

If it doesn't allow for this, then addon-styling-webpack is definite net loss over just using webpackFinal

export const addons = [
  "@storybook/addon-styling-webpack",
]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions