Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generating compiled CSS from SASS for Component Library #433

Open
dan-kez opened this issue Feb 28, 2018 · 9 comments
Open

Generating compiled CSS from SASS for Component Library #433

dan-kez opened this issue Feb 28, 2018 · 9 comments

Comments

@dan-kez
Copy link

dan-kez commented Feb 28, 2018

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.

@A11oW
Copy link

A11oW commented Mar 8, 2018

What about, if create task for nwb like as 'demo', which will be compile styles through webpack?

@smurrayatwork
Copy link

I'm having similar issues, here. @insin Any thoughts/comments on this issue? Thanks!

@RavenHursT
Copy link

@insin is this feature something that can be configured/implemented w/ the current architecture of nwb? Seems like there's a good amount of people trying to do this w/ components, but not much in the way of answers.... :-/

@samrith-s
Copy link

I'm struggling with this as well. I have a table component which heavily relies on CSS to style itself. So, I would like a way to package the stylesheet (SCSS) with the ES and Lib.

@aviskarkc10
Copy link

This might solve your problem #486

@YwainZ
Copy link

YwainZ commented Jun 24, 2019

@aviskarkc10

This might solve your problem #486

That's a good solution, but when i use modifyVars in nwb.config.js, It doesn't seem to work

nwb.config.js

less: {
        javascriptEnabled: true,
        modifyVars: {
          themeFile: process.argv.includes('--params') ? path.resolve(__dirname, './src/theme/themes.less') : null,
        },
      },

home.less

@import (optional) '@{themeFile}'

@aviskarkc10
Copy link

I am sorry I can't help you on this @Clairezyw. I used nwb in one pet project of mine for which I needed to compile sass and opened the PR because there wasn't any information out there. Maybe a maintainer of this project can help you. But this thread has been pretty inactive.

@insin

@busyzz-1994
Copy link

@samrith-s how to solve this problem?

I'm struggling with this as well. I have a table component which heavily relies on CSS to style itself. So, I would like a way to package the stylesheet (SCSS) with the ES and Lib.

@samrith-s
Copy link

@busyzz-1994 I stopped using this library 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants