{"id":21701425,"url":"https://github.com/ktsn/vue-media-loader","last_synced_at":"2025-04-12T13:37:32.280Z","repository":{"id":32505546,"uuid":"135692501","full_name":"ktsn/vue-media-loader","owner":"ktsn","description":"Enable `media` attribute on Vue SFC styles","archived":false,"fork":false,"pushed_at":"2023-01-07T02:26:42.000Z","size":1486,"stargazers_count":47,"open_issues_count":15,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-26T08:12:15.344Z","etag":null,"topics":["media-query","single-file-component","style","vue","webpack-loader"],"latest_commit_sha":null,"homepage":null,"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/ktsn.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":"2018-06-01T08:47:51.000Z","updated_at":"2022-11-27T10:02:24.000Z","dependencies_parsed_at":"2023-01-14T21:26:19.179Z","dependency_job_id":null,"html_url":"https://github.com/ktsn/vue-media-loader","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ktsn%2Fvue-media-loader","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ktsn%2Fvue-media-loader/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ktsn%2Fvue-media-loader/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ktsn%2Fvue-media-loader/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ktsn","download_url":"https://codeload.github.com/ktsn/vue-media-loader/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248574138,"owners_count":21126957,"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":["media-query","single-file-component","style","vue","webpack-loader"],"created_at":"2024-11-25T20:19:54.942Z","updated_at":"2025-04-12T13:37:32.261Z","avatar_url":"https://github.com/ktsn.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# vue-media-loader\n\nEnable `media` attribute on Vue SFC styles.\n\n## Requirements\n\n- vue-loader \u003e= 15\n\n## Installation\n\n```sh\n$ npm i -D vue-media-loader\n```\n\n## Usage\n\nAdd `vue-loader` and `vue-media-loader` in your webpack config. Note that you need to insert `vue-media-loader` between any CSS preprocessors and `css-loader`.\n\n```js\nconst VueLoaderPlugin = require('vue-loader/lib/plugin')\n\nmodule.exports = {\n  // ... Other configs goes here ...\n\n  module: {\n    rules: [\n      {\n        test: /\\.vue$/,\n        use: 'vue-loader'\n      },\n      {\n        test: /\\.scss$/,\n        use: [\n          'vue-style-loader',\n          'css-loader',\n          'vue-media-loader',\n          'sass-loader'\n        ]\n      }\n    ]\n  },\n\n  plugins: [new VueLoaderPlugin()]\n}\n```\n\nThen you can write `media` attribute on `\u003cstyle\u003e` block in your `.vue` files.\n\n```vue\n\u003ctemplate\u003e\n  \u003cp class=\"message\"\u003eThis text color will be changed if you change the window width.\u003c/p\u003e\n\u003c/template\u003e\n\n\u003cstyle\u003e\n.message {\n  color: #333;\n}\n\u003c/style\u003e\n\n\u003cstyle media=\"(max-width: 767px)\"\u003e\n.message {\n  color: #33a;\n}\n\u003c/style\u003e\n\n\u003cstyle media=\"(max-width: 320px)\"\u003e\n.message {\n  color: #a33;\n}\n\u003c/style\u003e\n```\n\nThe above code is equivalent with the following:\n\n```vue\n\u003ctemplate\u003e\n  \u003cp class=\"message\"\u003eThis text color will be changed if you change the window width.\u003c/p\u003e\n\u003c/template\u003e\n\n\u003cstyle\u003e\n.message {\n  color: #333;\n}\n\n@media (max-width: 767px) {\n  .message {\n    color: #33a;\n  }\n}\n\n@media (max-width: 320px) {\n  .message {\n    color: #a33;\n  }\n}\n\u003c/style\u003e\n```\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fktsn%2Fvue-media-loader","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fktsn%2Fvue-media-loader","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fktsn%2Fvue-media-loader/lists"}