Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/ryoppippi/svelte-preprocess-css-mods

use css modules in svelte
https://github.com/ryoppippi/svelte-preprocess-css-mods

css-modules cssmodules svelte svelte-preprocessor sveltekit

Last synced: about 16 hours ago
JSON representation

use css modules in svelte

Awesome Lists containing this project

README

        

# svelte-preprocess-css-mods

[![npm version](https://img.shields.io/npm/v/svelte-preprocess-css-mods?color=yellow)](https://npmjs.com/package/svelte-preprocess-css-mods)
[![npm downloads](https://img.shields.io/npm/dm/svelte-preprocess-css-mods?color=yellow)](https://npmjs.com/package/svelte-preprocess-css-mods)

[![JSR](https://jsr.io/badges/@ryoppippi/svelte-preprocess-css-mods)](https://jsr.io/@ryoppippi/svelte-preprocess-css-mods)
[![JSR](https://jsr.io/badges/@ryoppippi/svelte-preprocess-css-mods/score)](https://jsr.io/@ryoppippi/svelte-preprocess-css-mods)

Successor of [svelte-preprocess-cssmodules](https://github.com/micantoine/svelte-preprocess-cssmodules)

## Installation

```bash
npx nypm add -D svelte-preprocess-css-mods
```

## Usage

### Config

```javascript
// svelte.config.js

import { cssModules } from 'svelte-preprocess-css-mods';

export default {
preprocess: cssModules({/* options */}),
};
```

See [options](./src/options.ts) for more information.

### Svelte

```svelte

import styles from './App.module.css';


Hello World!



```

```css
/* App.module.css */
.container {
display: flex;
justify-content: center;
align-items: center;
}

.title {
color: red;
}
```

get converted into:

```svelte

const styles = {
container: 'App_module_container',
title: 'App_module_title',
};


Hello World!


.App_module_container {
display: flex;
justify-content: center;
align-items: center;
}

.App_module_title {
color: red;
}

```

## Related Works

- [svelte-true-css-modules](https://github.com/naumstory/svelte-true-css-modules)
- [svelte-preprocess-cssmodules](https://github.com/micantoine/svelte-preprocess-cssmodules)
- [I forked this project](https://github.com/ryoppippi/svelte-preprocess-cssmodules), but I gave it up

## License

[MIT](./LICENSE)