{"id":15044813,"url":"https://github.com/iminside/candy-loader","last_synced_at":"2025-10-24T14:30:37.062Z","repository":{"id":57193587,"uuid":"464463723","full_name":"iminside/candy-loader","owner":"iminside","description":"Load css files as pure jsx components with classnames as boolean props","archived":false,"fork":false,"pushed_at":"2022-03-18T14:18:52.000Z","size":4150,"stargazers_count":7,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-09-27T19:41:03.554Z","etag":null,"topics":["css","jsx","react","webpack","webpack-loader"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/iminside.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-02-28T11:57:15.000Z","updated_at":"2023-07-20T19:14:48.000Z","dependencies_parsed_at":"2022-09-15T22:31:04.671Z","dependency_job_id":null,"html_url":"https://github.com/iminside/candy-loader","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iminside%2Fcandy-loader","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iminside%2Fcandy-loader/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iminside%2Fcandy-loader/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iminside%2Fcandy-loader/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/iminside","download_url":"https://codeload.github.com/iminside/candy-loader/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":219868597,"owners_count":16555871,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["css","jsx","react","webpack","webpack-loader"],"created_at":"2024-09-24T20:51:04.690Z","updated_at":"2025-10-24T14:30:36.467Z","avatar_url":"https://github.com/iminside.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"![](https://habrastorage.org/webt/t2/i8/72/t2i872xwmelpxkvov0be1dgo5-q.png)\n\n\u003cdiv align=\"center\"\u003e\n\u003cimg src=\"https://img.shields.io/github/workflow/status/iminside/candy-loader/Node.js%20CI/master\" alt=\"GitHub Workflow Status (branch)\" /\u003e \n\u003cimg src=\"https://img.shields.io/github/languages/top/iminside/candy-loader\" alt=\"language\" /\u003e\n\u003cimg src=\"https://img.shields.io/npm/l/candy-loader\" alt=\"license\" /\u003e  \n\u003c/div\u003e\n\n# Webpack Candy loader\n\nLoad css files as pure react jsx components with classnames as boolean props\n\n## Install\n\n```bash\nnpm i -D candy-loader\n```\n\n## Settings\n\nUpdate the loaders in your `webpack.config.js` file.\n\n```js\n{\n    rules: [\n        {\n            test: /\\.css$/,\n            use: ['style-loader', 'candy-loader'],\n        },\n    ],\n}\n```\n\n## Usage\n\nUse classnames in camelCase mode\n\n```css\n/* style.css */\n\n.badge {\n    color: white;\n}\n.coral {\n    background-color: coral;\n}\n.green {\n    background-color: green;\n}\n```\n\nImport any html tag as pure jsx-component from css file\n\n```tsx\nimport { Div } from './style.css'\n\ninterface BadgeProps {\n    color: 'coral' | 'green'\n}\n\nconst Badge = (props: BadgeProps) =\u003e {\n    const isCoral = props.color === 'coral'\n    const isGreen = props.color === 'green'\n\n    return (\n        \u003cDiv badge coral={isCoral} green={isGreen}\u003e\n            Badge\n        \u003c/Div\u003e\n    )\n}\n```\n\n## Imports\n\nYou can include css files and access their styles.\n\n```css\n/* styles.css */\n@import 'grid.css';\n\n.root {\n    /*...*/\n}\n```\n\n```tsx\nimport { Div } from './styles.css'\n\nfunction Component(props) {\n    return (\n        \u003cDiv root col_xs_12 col_sm_8\u003e\n            ...\n        \u003c/Div\u003e\n    )\n}\n```\n\n## Pass css-variables\n\nIf a property starts with a double underscore, then its value can be retrieved using `var()` on any class applied to the element.\n\n```tsx\nimport { Div } from './styles.css'\n\nfunction Component(props) {\n    return (\n        \u003cDiv name __fontSize=\"14px\"\u003e\n            John\n        \u003c/Div\u003e\n    )\n}\n```\n\n```css\n.name {\n    color: black;\n    font-size: var(--fontSize);\n}\n```\n\n## Get styles like css-modules\n\n```css\n.box {\n    width: 50px;\n    height: 50px;\n}\n```\n\n```tsx\nimport styles from './styles.css'\n\nfunction Box(props) {\n    return \u003cdiv className={styles.box}\u003e...\u003c/div\u003e\n}\n```\n\n## Based on `postcss`\n\nYou can use the usual postcss config file\n\n```js\nmodule.exports = {\n    plugins: {\n        autoprefixer: isProduction,\n    },\n    processOptions: {\n        map: isDevelopment,\n    },\n}\n```\n\n## Intellisense\n\nUse [`typescript-plugin-candy`](https://github.com/iminside/typescript-plugin-candy) for type checking \u0026 autocomplete\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiminside%2Fcandy-loader","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fiminside%2Fcandy-loader","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiminside%2Fcandy-loader/lists"}