Skip to content

Commit

Permalink
chore: remove require
Browse files Browse the repository at this point in the history
  • Loading branch information
oscarmarina committed Nov 10, 2024
1 parent 50726e5 commit 29fdbe8
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 12 deletions.
38 changes: 28 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,20 @@

A simple SCSS watcher with autoprefixer.

### Why?
## Goals

- I want to use [SASS](https://github.com/sass/dart-sass) and [Lit](https://lit.dev/) to build **Web Components**.
- I prefer using ES Modules for CSS (CSS Modules) to leverage ES6 module features.
- I aim to keep it simple and independent of any bundler (_parcel, rollup, webpack_).
- Use [Lit](https://lit.dev/) + [SASS](https://github.com/sass/dart-sass) to build **Web Components**.
- Leverage ES6 module features to enable easy adoption of [import-attributes](https://fullystacked.net/import-attributes/) for [CSS module scripts](https://fullystacked.net/constructable/).
- Keep it simple and independent of any bundler such as _rollup, parcel, webpack_.

```js
// I don't want to use SASS directly in my code
import styles from './my-component-style.scss' 😟
```

> Lit makes it easy to _shim_ CSS Modules in a simple and lightweight way
<hr>

### Flow

- **my-component-styles.scss**

Expand Down Expand Up @@ -74,7 +76,7 @@ class MyComponent extends LitElement {

---

Or just, compile .scss files to .css file and then use [CSS module scripts](https://fullystacked.net/constructable/)
Or just, compile .scss files to .css file and then use [CSS module scripts](https://github.com/web-platform-tests/interop/issues/703)


```js
Expand Down Expand Up @@ -136,6 +138,17 @@ export const styles = css`

`npm i -D sass-style-template`

Here is an example of using [Vite](https://vite.dev/) + [concurrently](https://www.npmjs.com/package/concurrently) in the package scripts:

```js
// package.json
"scripts": {
"start": "concurrently -k -r \"npm:sass:watch\" \"npm:vite\"",
"vite": "vite",
"sass:watch": "sass-style-template"
}
```

### Options

**sass-style-template**
Expand All @@ -156,9 +169,9 @@ version(pkg.version, '-v, --version', 'show version number')

```js
// package.json
// my-component.scss --> my-component-styles.css.ts
"scripts": {
"start": "concurrently -k -r \"npm:sass:watch\" \"npm:vite\"",
"vite": "vite",
"sass:watch": "sass-style-template -j ts"
}
```
Expand All @@ -180,10 +193,15 @@ export const styles = css`<% content %>`;
Creating a custom template file in the root directory with the name `sass-template.tmpl`

```js
// https://github.com/material-components/material-web/blob/master/css-to-ts.js

// Example: sass-template.tmpl
// https://github.com/material-components/material-web/blob/main/scripts/css-to-ts.ts

/**
* @license
* Copyright 2024 XXX LLC
* SPDX-License-Identifier: Apache-2.0
*/
import {css} from 'lit';

export const styles = css`<% content %>`;
```

Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@blockquote/sass-style-template",
"version": "4.0.0-rc.5",
"description": "SASS and Lit for creating Web Components",
"version": "4.0.0",
"description": "A SCSS watcher with autoprefixer for building Web Components using Lit and SASS.",
"keywords": [
"lit",
"web-components",
Expand Down

0 comments on commit 29fdbe8

Please sign in to comment.