Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-static-plugin-raw-loader

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-static-plugin-raw-loader

A React-Static pulgin that allows importing files as a String.

  • 1.0.4
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
85
increased by49.12%
Maintainers
1
Weekly downloads
 
Created
Source

react-static-plugin-raw-loader

A React-Static plugin that allows importing files as a String.

Install

$ 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:

export default {
  // ...
  plugins: [
    // ...
    'react-static-plugin-raw-loader'
  ]
  // ...
};

Now you can import raw text as a String from *.txt file or *.md file.

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. Save this as yourcustomfilename.d.ts , and you can place it anywhere in your typescript project to take effect.

declare module "*.txt" {
  const content: string;
  export default content;
}

declare module "*.md" {
  const content: string;
  export default content;
}

Dependencies

  • 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 ).

    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.

FAQs

Package last updated on 25 Mar 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc