yaml-frontmatter-loader

YAML Frontmatter loader for webpack. Converts YAML in files to JSON. You should chain it with json-loader.

安装

npm install yaml-frontmatter-loader

用法

var json = require("json-loader!yaml-frontmatter-loader!./file.md");
// => 将 file.md 作为一个 javascript 对象返回

##

webpack.config.js

module.exports = {
  module: {
    rules: [
      {
         test: /\.md$/,
         use: [ 'json-loader', 'yaml-frontmatter-loader' ]
      }
    ]
  }
}

原文:https://webpack.js.org/loaders/yaml-frontmatter-loader/