Compile with:
webpack --config vendor.webpack.config.js
webpack --config app.webpack.config.js
Use with the following index.html
<script src="build/vendor.bundle.js"></script>
<script src="build/app.bundle.js"></script>
var square = require('./vendor'); | |
console.log(square(7)); |
var webpack = require('webpack'); | |
module.exports = { | |
entry: { | |
app: ['./app'], | |
}, | |
output: { | |
filename: 'app.bundle.js', | |
path: 'build/', | |
}, | |
plugins: [new webpack.DllReferencePlugin({ | |
context: '.', | |
manifest: require('./build/vendor-manifest.json'), | |
})] | |
}; |
function square(n) { | |
return n*n; | |
} | |
module.exports = square; |
var webpack = require('webpack'); | |
module.exports = { | |
entry: { | |
vendor: ['./vendor'], | |
}, | |
output: { | |
filename: 'vendor.bundle.js', | |
path: 'build/', | |
library: 'vendor_lib', | |
}, | |
plugins: [new webpack.DllPlugin({ | |
name: 'vendor_lib', | |
path: 'build/vendor-manifest.json', | |
})] | |
}; |
Would be nice if a new version of this could be created for webpack 2 :)
@amilajack This does work with webpack 2 after modifying paths to be absolute instead of relative. I created a fork for that https://gist.github.com/Eoksni/83d1f1559e0ec00d0e89c33a6d763049
@arunsn43 I think the purpose of the DllPlugin is only to speed up the build process performance. What it allows to achieve is that you won't have to build your bundles referenced by the DLL if they didn't change. When you build for production, you only build once and then you push the result to the production server. I read that you can also use the DllPlugin for code splitting as well as you would with CommonsChunkPlugin. I'm not a webpack pro, that's just my 2 cents. :)