You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In my project I'm using both npm modules and bower components (with debowerify) which I want to bundle together as vendor.js while keeping my own code in an app.js bundle.
What I did so far is created the app.js bundle by setting external to the npm modules and bower components. To figure out what modules to set as external I read the dependencies from package.json and bower.json.
Now, in a similar fashion I would like to parse my codebase, see which requires are external modules and bundle them together.
How could I do this?
The text was updated successfully, but these errors were encountered:
Hello, anybody have a solution to the question above? I know it's very old, but I am now starting to use factor-bundle, and I am facing the same situation.
Factor Bundle has the ability to run a custom filter via the threshold option. So you could do:
#!/usr/bin/env node
varbrowserify=require('browserify')varfs=require('fs')varpath=require('path')varentries=[path.join(__dirname,'index.js')]varoutputFiles=[path.join(__dirname,'dist-main.js')]varb=browserify(entries)b.plugin('factor-bundle',{output: outputFiles,threshold: function(row,groups){// Get a relative directory to where we are buildingvarrPath=path.relative(__dirname,row.file)// Assuming our node_modules folder is in the same directory that we are// building in then just declare vendor files as those presiding in itreturn!!rPath.match(/^node_modules\//)}})b.bundle().pipe(fs.createWriteStream(path.join(__dirname,'dist-vendor.js')))
In my project I'm using both npm modules and bower components (with debowerify) which I want to bundle together as
vendor.js
while keeping my own code in anapp.js
bundle.What I did so far is created the
app.js
bundle by settingexternal
to the npm modules and bower components. To figure out what modules to set asexternal
I read the dependencies frompackage.json
andbower.json
.Now, in a similar fashion I would like to parse my codebase, see which requires are external modules and bundle them together.
How could I do this?
The text was updated successfully, but these errors were encountered: