{"id":18052465,"url":"https://github.com/ReactML/loader","last_synced_at":"2025-03-27T22:33:25.378Z","repository":{"id":54888049,"uuid":"231369061","full_name":"ReactML/loader","owner":"ReactML","description":"The webpack loader for Reactive Markup Language(RML).","archived":false,"fork":false,"pushed_at":"2021-01-22T06:23:10.000Z","size":95,"stargazers_count":2,"open_issues_count":6,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-10-18T21:05:52.837Z","etag":null,"topics":["css-modules","dsl","loader","markup-language","react","react-markup-language","rml","webpack-loader"],"latest_commit_sha":null,"homepage":"https://github.com/ReactML/ReactML","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ReactML.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-01-02T11:34:25.000Z","updated_at":"2021-03-24T22:00:53.000Z","dependencies_parsed_at":"2022-08-14T05:50:26.489Z","dependency_job_id":null,"html_url":"https://github.com/ReactML/loader","commit_stats":null,"previous_names":["reactml/rml-loader"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ReactML%2Floader","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ReactML%2Floader/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ReactML%2Floader/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ReactML%2Floader/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ReactML","download_url":"https://codeload.github.com/ReactML/loader/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":222183029,"owners_count":16944872,"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-modules","dsl","loader","markup-language","react","react-markup-language","rml","webpack-loader"],"created_at":"2024-10-30T23:11:52.626Z","updated_at":"2024-10-30T23:11:53.464Z","avatar_url":"https://github.com/ReactML.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @reactml/loader\n\nThe `@reactml/loader` impl the webpack loader for [React Markup Language(RML)](https://github.com/ReactML/ReactML).\n\n## Usage\n\nTo begin, you'll need to install `@reactml/loader`:\n\n```console\nnpm install --save-dev @reactml/loader\n```\n\nThen add the plugin to your `webpack` config. \n\nFor example:\n\n**file.js**\n\n```js\nimport Module from './module.rml';\n```\n\n**webpack.config.js**\n\n```js\nmodule.exports = {\n  module: {\n    rules: [\n      {\n        test: /\\.rml$/i,\n        loader: '@reactml/loader',\n        options: {\n          renderer: 'react',\n        },\n      },\n    ],\n  },\n};\n```\n\n### Options\n\n- renderer {String} Determin react replacement renderer. (default to 'react')\n\nAnd run `webpack` via your preferred method.\n\n\n\n## CSS PreProcessor Support\n\nFor example, to compile our `\u003cstyle\u003e` tag with Scss:\n\n\u003e Tips: Default lang is`css`.\n\nIn your webpack config:\n\n```js\nmodule.exports = {\n  module: {\n    rules: [\n      // this will apply to both plain `.scss` files\n      // AND `\u003cstyle lang=\"scss\"\u003e` blocks in `.rml` files\n      {\n        test: /\\.scss$/,\n        use: [\n          'style-loader',\n          'css-loader',\n          'sass-loader'\n        ]\n      }\n    ]\n  },\n}\n```\n\nAny content inside the style block with `lang=\"scss\"`  will be processed by webpack as if it's inside a `*.scss` file.\n\n```html\n\u003cstyle lang=\"scss\"\u003e\n/* Write SCSS here */\n\u003c/style\u003e\n```\n\n## CSS Modules\n\nFirst, CSS Modules must be enabled by passing `modules: true` to `css-loader`:\n\n```js\n// webpack.config.js\n{\n  module: {\n    rules: [\n      // ... other rules omitted\n      {\n        test: /\\.css$/,\n        use: [\n          'style-loader',\n          {\n            loader: 'css-loader',\n            options: {\n              // enable CSS Modules\n              modules: true,\n            }\n          }\n        ]\n      }\n    ]\n  }\n}\n```\n\nThen, add the module attribute to your `\u003cstyle\u003e`，and use `className` as is:\n\n```html\n\u003cstyle module\u003e\n.red {\n  color: red;\n}\n.bold {\n  font-weight: bold;\n}\n\u003c/style\u003e\n\n\u003cdiv className=\"red bold\"\u003eHello RML\u003c/div\u003e\n```\n\n### Use global scope in CSS Modules:\n\n\u003e Only works when CSS Moudles is enabled.\n\nYou can add suffix `:` to your class declaration to tag which to be gloabl,\n\nFor example:\n\n```html\n\u003cstyle lang=\"scss\" module\u003e\n  .container {\n    color: green;\n  }\n\n  :global {\n    .global-container {\n      background: grey;\n    }\n  }\n\u003c/style\u003e\n\u003cdiv className=\"container :global-container\" /\u003e\n```\n\nAfter compiled, global scope className will not be invoved:\n\n```html\n\u003cstyle\u003e\n  ._2zQP9LGGLck7rMhc9zNHw_ {\n    color: green;\n  }\n\n  .global-container {\n     background: grey;\n   }\n\u003c/style\u003e\n\u003cdiv class=\"_2zQP9LGGLck7rMhc9zNHw_ global-container\" /\u003e\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FReactML%2Floader","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FReactML%2Floader","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FReactML%2Floader/lists"}