Skip to content

kristianmandrup/raw-text-loader

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

raw-text-loader

Webpack loader to load pure raw text.

Install & Usage

npm i raw-text-loader --save-dev

Add loader config to your webpack config file, f.ex webpack.base.conf.js

module: {
    loaders: [
      {
        test: /\.txt$/,
        loader: 'raw-text'
      },
      // ...
}

Use case

In a recent Web app, I wanted to load text blocks from files instead of inlining or making a server request. The text will thus be inlined at compile time by Webpack :)

  code: {
    vm: require('raw!../examples/breadcrumb/vm.js.txt'),
    view: require('raw!../examples/breadcrumb/view.html.txt')
  }

In this case, I used these files to display highlighted code examples.

Similar projects

text-loader raw-loader

These loaders both return the file content wrapped with: module.exports = JSON.stringify(content);.

License

MIT

About

Webpack loader to polyfill for Requires' text loader module

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%