ware-loader

A loader for webpack that let you change your source in loader.

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
ware-loader
22180.2.46 years ago6 years agoMinified + gzip package size for ware-loader in KB

Readme

!npmnpmnpm-url !depsdepsdeps-url
Ware Loader

A loader for webpack that let you change your source in loader.


Install


npm install --save-dev ware-loader

Examples


Use the loader either via your webpack config. Here is an example to parse markdown file as vue component.

Via webpack config (recommended)

webpack.config.js
const MarkdownIt = require('markdonw-it')
const md = new MarkdownIt()

module.exports = {
  module: {
    rules: [
      {
        test: /\.md$/,
        loader: 'ware-loader',
        enforce: 'pre',
        options: {
          raw: true,
          middleware: function(source) {
            return `<template><div>${md.render(source)}</div></template>`
          }
        }
      },
      {
        test: /\.md$/,
        use: 'vue-loader'
      }
    ]
  }
}

In your application
import Doc from './doc.md';

Options


| Option | Description | Type | Default| |---------- |-------------------- |---------|-------- | | raw | If set to false, source will be wrapped with 'module.exports = ' + source | boolean | false | | async | Whehter middleware should be async function | boolean | false | | middleware | Functions to change source | function, function | - |

Maintainers


<tr>
  <td align="center">
    <img width="150" height="150"
    src="https://avatars3.githubusercontent.com/u/16029685?v=3&s=150">
    </br>
    <a href="https://github.com/liril-net">Cyril Su</a>
  </td>
</tr>