1.0.1 • Published 6 years ago

injection-loader v1.0.1

Weekly downloads
24
License
MIT
Repository
github
Last release
6 years ago

Injection Loader

A loader for webpack that lets you inject content to file.

Install

npm install --save-dev injection-loader raw-loader

Usage

Use the loader either via your webpack config, CLI or inline.

Note: Injection loader just INJECTION (guidelines), you can use it with raw-loader to require non-js file.

webpack.config.js:

module.exports = {
  module: {
    rules: [{
      test: /\.md$/,
      use: [
        {
          loader: 'raw-loader',
        },
        {
          loader: 'injection-loader',
          options: {
            // default pattern
            pattern: /__INCLUDE_FILE\('(.+)'\)/,
          },
        }
      ]
    }]
  }
}

In your application

import md from 'some.md';

some.md:

# Title

## Sub title

- list 1
- list 1

__INCLUDE_FILE('./injection.txt')

Note: __INCLUDE_FILE path (./injection.txt) should RELATIVE to some.md.