Created
January 30, 2017 16:03
-
-
Save sgrasso/9ad01043539e41e36030f5b498a19eae to your computer and use it in GitHub Desktop.
Webpack DLL example using Webpack-Config
This file contains 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
'use strict'; | |
const path = require('path'); | |
const webpack = require('webpack'); | |
const WebpackConfig = require('webpack-config').Config; | |
module.exports = new WebpackConfig().merge({ | |
name: 'myapp', | |
//Remove in production or change to 'source-map' | |
devtool: 'cheap-module-eval-source-map', | |
cache: true, | |
//Report the first error as a hard error instead of tolerating it | |
bail: true, | |
output: { | |
path: path.join(process.cwd(), 'public/js/'), | |
publicPath: '/public/assets/js/', | |
filename: '[name].[chunkhash].js', | |
chunkFilename: '[chunkhash].js' | |
}, | |
plugins: [ | |
new webpack.DllReferencePlugin({ | |
context: '.', | |
manifest: require(path.join(process.cwd(), 'config/manifests/vendor_manifest.json')) | |
}), | |
new webpack.optimize.DedupePlugin(), | |
new webpack.optimize.UglifyJsPlugin({ | |
compress: { | |
warnings: false | |
} | |
}) | |
] | |
}); |
This file contains 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
'use strict'; | |
const path = require('path'); | |
const webpack = require('webpack'); | |
const WebpackConfig = require('webpack-config').Config; | |
module.exports = new WebpackConfig().merge({ | |
name: 'vendor', | |
//Base Alias to be shared. | |
alias: { | |
jquery: 'node_modules/jquery/src/jquery.js', | |
handlebars: 'node_modules/handlebars/runtime.js', | |
intl: 'node_modules/intl/dist/Intl.js', | |
'handlebars-intl': 'node_modules/handlebars-intl/dist/handlebars-intl.js', | |
bootstrap: 'node_modules/bootstrap/dist/js/npm.js', | |
underscore: 'node_modules/underscore/underscore.js' | |
}, | |
entry: { | |
// create one library bundle that can be shared. | |
vendor: [ | |
'jquery', | |
'handlebars', | |
'intl', | |
'handlebars-intl', | |
'bootstrap', | |
'underscore' | |
] | |
}, | |
output: { | |
// The name of the global variable which the library's | |
// require() function will be assigned to | |
library: 'vendor_lib' | |
}, | |
plugins: [ | |
new webpack.DllPlugin({ | |
// The name of the global variable which the library's | |
// require function has been assigned to. This must match the | |
// output.library option above | |
name: 'vendor_lib', | |
// The path to the manifest file which maps between | |
// modules included in a bundle and the internal IDs | |
// within that bundle | |
path: path.join(process.cwd(), 'config/manifests/vendor_manifest.json') | |
}), | |
new webpack.optimize.UglifyJsPlugin({ | |
compress: { | |
warnings: false | |
} | |
}) | |
], | |
//Default Path that /node_modules/ resovles to for loaders. | |
resolveLoader: { | |
root: path.join(process.cwd(), 'node_modules') | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment