Inject into .js file
See original GitHub issueI’m trying to inject a js dependency into a .js file, so I could lazy load that file later. In my Angular use case it looks like this:
// analytics-module.js that is later get concatinated to app.js
$ocLazyLoad.load({
name: 'angles',
files: ['<!-- inject:analytics:js --><!-- endinject -->']
}).then(function() {
// Show analytics
});
Im trying to achive it with the following task:
// gulpfile.js
gulp.src('_public/js/app*.js')
.pipe(inject(gulp.src(["_public/js/vendor-analytics*.js"], { read: false }), {
ignorePath: '/_public/',
starttag: '<!-- inject:analytics:js -->',
transform: function (filepath, file, i, length) {
return filepath;
}
}))
.pipe(gulp.dest("_public/"));
I’m getting the following output: gulp-inject 1 files into app.js.
, but in reality the placeholder for the file does not get changed to the filepath.
Does injection into .js files is supported? In there a way to debug it somehow?
Issue Analytics
- State:
- Created 9 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
Inject external javascript file in html body after page load
I want to load an external javascript after page ...
Read more >How to Inject JavaScript Code to Manipulate Websites ...
1. Installing the Extension to Inject the Code ... The following only applies if you use Google Chrome. Install the extension custom JavaScript...
Read more >Inject Javascript with references to other Js files - UiPath Forum
I have a task to Inject java script into a Hmtl page and execute the java script code which returns the output. HTML...
Read more >injectJs - PhantomJS
Injects external script code from the specified file into the page (like page.includeJs , except that the file ... Inject do.js file into...
Read more >klei/gulp-inject: A javascript, stylesheet and ... - GitHub
gulp-inject takes a stream of source files, transforms each file to a string and injects each transformed string into placeholders in the target...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’m afraid that’s not possible, see #59 .
In your case maybe this can work:
Then your files will be injected into the files array, and even comma separate the files if there’s more than one file.
Hello I am also facing issue but not similar I want to inject variable to JS file. so how can I achieve this.