Skip to content

Latest commit

 

History

4 提交

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

仓库 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 参数替换,路径的前部分
              }
            }
          }
        ]
      }
    ]
  }
}

关于

raw tree replace for webpack

Topics

Resources

Stars

1 star

关注者

1 watching

复刻s

发布

Used by

贡献者

Languages