Reputation: 10647
I have an app built with Node-Gulp-Webpack.
I have an external JavaScript file external.js
that is not local to my app, but I want to be able to require
it in my app. This file is on a path for which there is an environment variable named MY_PATH
.
How can I include this external.js
as-is in my build without making a Node module out of it?
So far, this does not work and doesn't return a useful error message:
var external = require(process.env.MY_PATH + '/external.js');
Upvotes: 1
Views: 1325
Reputation: 4464
Use gulp-remote-src, the example:
var gulp = require('gulp');
var uglify = require('gulp-uglify');
var remoteSrc = require('gulp-remote-src');
gulp.task('remote', function() {
remoteSrc(['app.js', 'jquery.js'], {
base: 'http://myapps.com/assets/',
})
.pipe(uglify())
.pipe(gulp.dest('./dist/'));
})
Upvotes: 1