Skip to content

Exclude node_modules files by default when setting up via markbind init #1844

Description

@tlylt

Tell us about your environment
Windows 10

  • MarkBind Version:
    v3.1.1
    What did you do? Please include the actual source code causing the issue.
    I think it is pretty complicated for someone new with MarkBind to do a simple task such as ignoring files from node_modules. This is a common scenario when starting a js project and adding MarkBind to it. I took some time myself in order to figure out how to do it and initially thought that it was bug 😢

A typical project initialization process might look like this:

  1. Start a new js project npm init
  2. Install the latest version of markbind-cli npm i markbind-cli
  3. Add in the package.json's script that "build": "markbind build", "init": "markbind init"
  4. initialize a markbind project npm run init
  5. try building the project by npm run build
    • will copy and build all the files in node_modules
    • not what is expected
    • read the docs to discover the ignore attribute
  6. try adding "node_modules/*" in site.json's ignore attribute
  7. try building the project by npm run build
    • doesn't quite work, still tries to build 500 plus pages, and ended with an error
    • possibly due to the glob pattern of "**/*.+(md|mbd)"
    • read the docs again to figure out that there's a globExcludes that works with glob (I initially thought that it is defined in a separate object and that doesn't work)
  8. try adding "node_modules/*" in a globExcludes:
    Note that this doesn't work, but it's the first thing I tried:
    {
      "glob": ["**/index.md", "**/*.+(md|mbd)"],
    },
	{
      "globExclude": ["node_modules/*"]
	}

This works

    {
      "glob": ["**/index.md", "**/*.+(md|mbd)"],
      "globExclude": ["node_modules/*"]
    }
  1. possibly also realize that this will work:
"pagesExclude": ["node_modules/*"],

What did you expect to happen?
I expect the common task to be simple.

What actually happened? Please include the actual, raw output.
Currently, it requires a new user to understand a few attributes such as 'ignore', 'glob', 'globExcludes', 'pagesExclude' just to get started.
This could be due to the fact that we only mention how to globally install markbind-cli in our user guide. While that works, it may not work well for existing projects or those that already have the setup of a package.json with node_modules. My proposal is as follows:

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions