{"id":13508863,"url":"https://github.com/webpack-contrib/raw-loader","last_synced_at":"2025-03-30T11:32:53.367Z","repository":{"id":50746161,"uuid":"3948742","full_name":"webpack-contrib/raw-loader","owner":"webpack-contrib","description":" A loader for webpack that allows importing files as a String","archived":true,"fork":false,"pushed_at":"2021-03-08T18:31:52.000Z","size":1515,"stargazers_count":845,"open_issues_count":5,"forks_count":91,"subscribers_count":15,"default_branch":"master","last_synced_at":"2025-03-17T11:48:31.950Z","etag":null,"topics":["files","raw","webpack-loader"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/webpack-contrib.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":".github/CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null},"funding":{"open_collective":"webpack"}},"created_at":"2012-04-06T10:26:20.000Z","updated_at":"2025-03-07T05:50:51.000Z","dependencies_parsed_at":"2022-08-12T22:10:45.996Z","dependency_job_id":null,"html_url":"https://github.com/webpack-contrib/raw-loader","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webpack-contrib%2Fraw-loader","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webpack-contrib%2Fraw-loader/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webpack-contrib%2Fraw-loader/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webpack-contrib%2Fraw-loader/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/webpack-contrib","download_url":"https://codeload.github.com/webpack-contrib/raw-loader/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246085609,"owners_count":20721211,"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":["files","raw","webpack-loader"],"created_at":"2024-08-01T02:00:59.600Z","updated_at":"2025-03-30T11:32:52.902Z","avatar_url":"https://github.com/webpack-contrib.png","language":"JavaScript","readme":"\u003cdiv align=\"center\"\u003e\n  \u003cimg width=\"200\" height=\"200\"\n    src=\"https://cdn3.iconfinder.com/data/icons/lexter-flat-colorfull-file-formats/56/raw-256.png\"\u003e\n  \u003ca href=\"https://github.com/webpack/webpack\"\u003e\n    \u003cimg width=\"200\" height=\"200\"\n      src=\"https://webpack.js.org/assets/icon-square-big.svg\"\u003e\n  \u003c/a\u003e\n\u003c/div\u003e\n\n[![npm][npm]][npm-url]\n[![node][node]][node-url]\n[![deps][deps]][deps-url]\n[![tests][tests]][tests-url]\n[![coverage][cover]][cover-url]\n[![chat][chat]][chat-url]\n[![size][size]][size-url]\n\n# raw-loader\n\n**DEPREACTED for v5**: please consider migrating to [`asset modules`](https://webpack.js.org/guides/asset-modules/).\n\nA loader for webpack that allows importing files as a String.\n\n## Getting Started\n\nTo begin, you'll need to install `raw-loader`:\n\n```console\n$ npm install raw-loader --save-dev\n```\n\nThen add the loader to your `webpack` config. For example:\n\n**file.js**\n\n```js\nimport txt from './file.txt';\n```\n\n**webpack.config.js**\n\n```js\n// webpack.config.js\nmodule.exports = {\n  module: {\n    rules: [\n      {\n        test: /\\.txt$/i,\n        use: 'raw-loader',\n      },\n    ],\n  },\n};\n```\n\nAnd run `webpack` via your preferred method.\n\n## Options\n\n|            Name             |    Type     | Default | Description            |\n| :-------------------------: | :---------: | :-----: | :--------------------- |\n| **[`esModule`](#esmodule)** | `{Boolean}` | `true`  | Uses ES modules syntax |\n\n### `esModule`\n\nType: `Boolean`\nDefault: `true`\n\nBy default, `raw-loader` generates JS modules that use the ES modules syntax.\nThere are some cases in which using ES modules is beneficial, like in the case of [module concatenation](https://webpack.js.org/plugins/module-concatenation-plugin/) and [tree shaking](https://webpack.js.org/guides/tree-shaking/).\n\nYou can enable a CommonJS module syntax using:\n\n**webpack.config.js**\n\n```js\nmodule.exports = {\n  module: {\n    rules: [\n      {\n        test: /\\.txt$/i,\n        use: [\n          {\n            loader: 'raw-loader',\n            options: {\n              esModule: false,\n            },\n          },\n        ],\n      },\n    ],\n  },\n};\n```\n\n## Examples\n\n### Inline\n\n```js\nimport txt from 'raw-loader!./file.txt';\n```\n\nBeware, if you already define loader(s) for extension(s) in `webpack.config.js` you should use:\n\n```js\nimport css from '!!raw-loader!./file.txt'; // Adding `!!` to a request will disable all loaders specified in the configuration\n```\n\n## Contributing\n\nPlease take a moment to read our contributing guidelines if you haven't yet done so.\n\n[CONTRIBUTING](./.github/CONTRIBUTING.md)\n\n## License\n\n[MIT](./LICENSE)\n\n[npm]: https://img.shields.io/npm/v/raw-loader.svg\n[npm-url]: https://npmjs.com/package/raw-loader\n[node]: https://img.shields.io/node/v/raw-loader.svg\n[node-url]: https://nodejs.org\n[deps]: https://david-dm.org/webpack-contrib/raw-loader.svg\n[deps-url]: https://david-dm.org/webpack-contrib/raw-loader\n[tests]: https://github.com/webpack-contrib/raw-loader/workflows/raw-loader/badge.svg\n[tests-url]: https://github.com/webpack-contrib/raw-loader/actions\n[cover]: https://codecov.io/gh/webpack-contrib/raw-loader/branch/master/graph/badge.svg\n[cover-url]: https://codecov.io/gh/webpack-contrib/raw-loader\n[chat]: https://img.shields.io/badge/gitter-webpack%2Fwebpack-brightgreen.svg\n[chat-url]: https://gitter.im/webpack/webpack\n[size]: https://packagephobia.now.sh/badge?p=raw-loader\n[size-url]: https://packagephobia.now.sh/result?p=raw-loader\n","funding_links":["https://opencollective.com/webpack"],"categories":["JavaScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwebpack-contrib%2Fraw-loader","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwebpack-contrib%2Fraw-loader","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwebpack-contrib%2Fraw-loader/lists"}