Skip to content
This repository was archived by the owner on Feb 15, 2025. It is now read-only.
This repository was archived by the owner on Feb 15, 2025. It is now read-only.

Generating compiled CSS from SASS for Component Library #433

Open
@dan-kez

Description

@dan-kez

This issue is a:

  • Question / support request

Hello!

I'm using nwb to build a component library for my team. I've run into an issue where a third party component is primarily theme-able via less / sass. I would like to generate a compile css file for this sass in my es / lib directories. This would allow my library consumers to forgo installing / updating their webpack configs to support compiling sass files from the modules.

Some additional information:

  • I am on "nwb": "0.21.x",
  • My build command is: nwb build-react-component --copy-files --keep-proptypes

I have attempted to do the above with the nwb-sass plugin. That said, I have not had success in generating css file in either the es or lib directories.

My current webpack config in nwb.config.js

{
  type: 'react-component',
  npm: {
    esModules: true,
    umd: false,
  },
  babel: {
    plugins: [
      'jsx-control-statements',
      ['module-resolver', {
        root: ['.'],
        alias: {
          Components: './src/Components',
          Constants: './src/Constants',
          Assets: './src/Assets',
          Utils: './src/Utils',
        },
      }],
    ],
  },
  webpack: {
    rules: {
      babel: {
        test: /\.jsx?/,
      },
      sass: {
        modules: true,
        localIdentName: '[hash:base64:5]',
      },
    },
    styles: {
      sass: [
        {
          sass: {
            modules: true,
            localIdentName: '[hash:base64:5]',
            sourceMap: true,
          },
        },
      ],
    },
    extra: {
      resolve: {
        extensions: ['.js', '.jsx', '.json', '.scss'],
      },
      node: {
        process: false,
      },
    },
    aliases: {
      Components: path.resolve(__dirname, 'src/Components'),
      Constants: path.resolve(__dirname, 'src/Constants'),
      Assets: path.resolve(__dirname, 'src/Assets'),
      Utils: path.resolve(__dirname, 'src/Utils'),
    },
  },
};

I would sincerely appreciate an example on how to configure my config to generate a css file given scss file or otherwise.

EDIT: Looking into this further it looks like webpackBuild isn't even being called when building the es and lib directories. (see

import webpackBuild from './webpackBuild'
).

I don't have any interest in building a full UMD build but I do require the css styling. I'm assuming this would require a PR unless I've missed something.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions