项目作者: react-doc

项目描述 :
raw tree replace for webpack
高级语言: JavaScript
项目地址: git://github.com/react-doc/raw-tree-replace-loader.git
创建时间: 2018-01-05T20:01:51Z
项目社区:https://github.com/react-doc/raw-tree-replace-loader

开源协议:

下载







Raw Tree Replace Loader


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


Install

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

webpack.config.js

  1. module.exports = {
  2. module: {
  3. rules: [
  4. {
  5. test: /\.json$/,
  6. use: [
  7. {
  8. loader: require.resolve('raw-tree-replace-loader'),
  9. options: {
  10. include: /rdoc\.tree\.data\.json$/, // 检查包含的文件名字
  11. extensions: /\.md/,
  12. directoryTrees: { // 指定目录生成目录树,json
  13. dir: ['/path/to/dir'],
  14. mdconf: true,
  15. extensions: /\.md/,
  16. relativePath: true, // 获取相对目录, dir 参数替换,路径的前部分
  17. }
  18. }
  19. }
  20. ]
  21. }
  22. ]
  23. }
  24. }

In Webpack 4

  1. module.exports = {
  2. module: {
  3. rules: [
  4. {
  5. test: /\.json$/,
  6. // Disable Webpack 4 Native JSON Loader
  7. + type: 'javascript/auto',
  8. use: [
  9. {
  10. loader: require.resolve('raw-tree-replace-loader'),
  11. options: {
  12. include: /rdoc\.tree\.data\.json$/, // 检查包含的文件名字
  13. extensions: /\.md/,
  14. directoryTrees: { // 指定目录生成目录树,json
  15. dir: ['/path/to/dir'],
  16. mdconf: true,
  17. extensions: /\.md/,
  18. relativePath: true, // 获取相对目录, dir 参数替换,路径的前部分
  19. }
  20. }
  21. }
  22. ]
  23. }
  24. ]
  25. }
  26. }