How do I manage relative path aliasing in multiple grunt-browserify bundles?

后端 未结 4 754
既然无缘
既然无缘 2020-12-08 02:28

This is tad long but I\'ll need the code example to illustrate my confusion. After which I am interested to the answer for the following:

  1. How do I use re
4条回答
  •  轮回少年
    2020-12-08 02:38

    I think the absolute best way to go is, as Sebastien Lorber notes, with setting the path in your calling of browserify through a pipe.

    But with the latest version of browserify, (as of this moment, that is browserify@11.0.0 ) the path variable stores the only paths that Browserify will use for its process. So setting the paths variable will exclude say... your global folders for node, as far as I can tell. As a result, you'll need a Gulp task that looks sort of like this:

    gulp.task('reactBuild', function() {
      return gulp.src(newThemeJSX)
        .pipe(browserify({
            debug: true,
            extensions: ['.jsx', '.js', '.json'],
            transform: [reactify],
            paths: ['../base_folder/node_modules', '/usr/lib/node_modules']
        }))
        .pipe(gulp.dest(newThemeBuilt))
        .on('error', function(error) {
            console.log(error);
        });
    });
    

提交回复
热议问题