# react-static-plugin-raw-loader
A [React-Static](https://react-static.js.org) plugin that allows importing files as a String.
## Install
```shell
$ npm install react-static-plugin-raw-loader
# or
$ yarn add react-static-plugin-raw-loader
```
## Use
Edit your `static.config.js` , add this plugin like this:
```js
export default {
// ...
plugins: [
// ...
'react-static-plugin-raw-loader'
]
// ...
};
```
Now you can import raw text as a String from `*.txt` file or `*.md` file.
```jsx
import React from 'react'
import textValue from 'something.txt'
const App = function() {
return (
<div>
<p>{textValue}</p>
<div/>
);
};
```
### For Typescript
For Typescript user, you may need type declaration. Add this to any .ts/.tsx file in your typescript project.
```ts
import 'react-static-plugin-raw-loader/raw.d' // import type declaration
```
## Dependencies
- [raw-loader](https://github.com/webpack-contrib/raw-loader)
As you can see from its README, raw-loader has been "deprecated" since Webpack v5 has added support for importing
asset files (see [asset modules ](https://webpack.js.org/guides/asset-modules/) ).
But React-Static are using Webpack v4 at present. So this dependency may become no longer necessary when React-Static
uses Webpack v5 in the future.
没有合适的资源?快使用搜索试试~ 我知道了~
react-static-plugin-raw-loader:一个React-Static插件,允许将文件作为字符串导入
共5个文件
md:1个
json:1个
ts:1个
1星 需积分: 9 1 下载量 68 浏览量
2021-03-25
16:04:21
上传
评论
收藏 3KB ZIP 举报
温馨提示
react-static-plugin-raw-loader 一个插件,允许将文件作为字符串导入。 安装 $ npm install react-static-plugin-raw-loader # or $ yarn add react-static-plugin-raw-loader 使用 编辑您的static.config.js ,像这样添加此插件: export default { // ... plugins : [ // ... 'react-static-plugin-raw-loader' ] // ... } ; 现在,您可以从*.txt文件或*.md文件将原始文本作为字符串导入。 import React from 'react' import textValue from 'something.txt' const App =
资源详情
资源评论
资源推荐
收起资源包目录
react-static-plugin-raw-loader-main.zip (5个子文件)
react-static-plugin-raw-loader-main
raw.d.ts 156B
LICENSE 1KB
README.md 1KB
node.api.js 320B
package.json 291B
共 5 条
- 1
寂寞孩纸
- 粉丝: 39
- 资源: 4473
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论1