Skip to content

Experiment to use Webpack loaders with CSS modules and Constructable StyleSheets

Notifications You must be signed in to change notification settings

spmonahan/constructable-stylesheets-webpack

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Constructable Stylesheets with Webpack

This repo is an experiment to see if Webpack loaders can be used with CSS modules to produce constructable stylesheets for use with custom element (i.e., shadow DOM).

Usage

  1. yarn: install deps
  2. yarn webpack: build the app
  3. yarn serve: serve the app

Background

Essentially the goal is to be able do the following (pseudo code ahead!):

// A React component
import * as styles from './styles.css' assert { type: 'css' };
document.adoptedStyleSheets = [...document.adoptedStylesheets, styles.default];

const MyReactComponent = () => {
    return <div className={styles.myCssModuleClassName}>React component with CSS modules</div>
};

// Using react-shadow (https://www.npmjs.com/package/react-shadow)
return <root.div styleSheets={document.adoptedStylesSheets}>
    <MyReactComponent />
</root.div>;

About

Experiment to use Webpack loaders with CSS modules and Constructable StyleSheets

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published