Compile with:
webpack --config vendor.webpack.config.js
webpack --config app.webpack.config.jsUse 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', | |
| })] | |
| }; |