Compiling dynamically required modules with Browserify

后端 未结 3 1409
广开言路
广开言路 2020-12-06 01:00

I am using Browserify to compile a large Node.js application into a single file (using options --bare and --ignore-missing [to avoid troubles with

3条回答
  •  无人及你
    2020-12-06 01:44

    This plugin allows to require Glob patterns: require-globify

    Then, with a little hack you can add all the files on compilation and not executing them:

    // Hack to compile Glob files. Don´t call this function!
    function ಠ_ಠ() {
      require('views/**/*.js', { glob: true })
    }
    

    And, for example, you could require and execute a specific file when you need it :D

    var homePage = require('views/'+currentView)
    

提交回复
热议问题