Skip to content

react-doc/raw-tree-replace-loader

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Raw Tree Replace Loader

Replace the specified JSON file with the contents of the directory tree.

Install

npm install --save-dev raw-tree-replace-loader

webpack.config.js

module.exports = {
  module: {
    rules: [
      {
        test: /\.json$/,
        use: [
          {
            loader: require.resolve('raw-tree-replace-loader'),
            options: {
              include: /rdoc\.tree\.data\.json$/, // 检查包含的文件名字
              extensions: /\.md/,
              directoryTrees: { // 指定目录生成目录树,json
                dir: ['/path/to/dir'],
                mdconf: true,
                extensions: /\.md/,
                relativePath: true, // 获取相对目录, dir 参数替换,路径的前部分
              }
            }
          }
        ]
      }
    ]
  }
}

In Webpack 4

module.exports = {
  module: {
    rules: [
      {
        test: /\.json$/,
        // Disable Webpack 4 Native JSON Loader
+        type: 'javascript/auto',
        use: [
          {
            loader: require.resolve('raw-tree-replace-loader'),
            options: {
              include: /rdoc\.tree\.data\.json$/, // 检查包含的文件名字
              extensions: /\.md/,
              directoryTrees: { // 指定目录生成目录树,json
                dir: ['/path/to/dir'],
                mdconf: true,
                extensions: /\.md/,
                relativePath: true, // 获取相对目录, dir 参数替换,路径的前部分
              }
            }
          }
        ]
      }
    ]
  }
}

Releases

No releases published

Packages

No packages published