Created
January 8, 2020 19:19
-
-
Save chrishalebarnes/92187b0ac0d6f5d7f84b9534aa03ad55 to your computer and use it in GitHub Desktop.
Browerify Example with Treeshaking and a Split Vendor Bundle
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const browserify = require('browserify'); | |
const fs = require('fs'); | |
const hbsfy = require("hbsfy"); | |
const treeshake = require('common-shakeify') | |
const factor = require('factor-bundle'); | |
const path = require('path'); | |
browserify({ | |
entries: [ path.resolve('app/main.js'), path.resolve('app/another-entry.js') ], | |
paths: [ './node_modules','./app' ], | |
extensions: [ '.js', '.hbs' ] | |
}) | |
.plugin(factor, { outputs: [ 'dist/main.js', 'dist/another-entry.js' ] }) | |
.transform(hbsfy.configure({ extensions: [ 'hbs' ] })) | |
.transform('babelify') | |
.plugin(treeshake) | |
.bundle().pipe(fs.createWriteStream(process.cwd() + '/dist/vendor.js')); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
node build.js |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment