Introduce DllPlugin

pull/2903/head
Andrew Watkins 2018-02-24 11:31:39 -07:00
parent 5eff3ef204
commit 1f9f93460b
3 changed files with 48 additions and 12 deletions

View File

@ -1,10 +1,16 @@
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<title>Chronograf</title> <title>Chronograf</title>
</head> </head>
<body> <body>
<div id='react-root' data-basepath=""></div> <div id='react-root' data-basepath=""></div>
<script type="text/javascript" src="/vendor/vendor.dll.js"></script>
</body> </body>
</body>
</html> </html>

View File

@ -39,7 +39,6 @@ module.exports = {
devtool: 'inline-eval-cheap-source-map', devtool: 'inline-eval-cheap-source-map',
entry: { entry: {
app: path.resolve(__dirname, '..', 'src', 'index.js'), app: path.resolve(__dirname, '..', 'src', 'index.js'),
vendor: Object.keys(dependencies),
}, },
output: { output: {
publicPath: '/', publicPath: '/',
@ -132,6 +131,10 @@ module.exports = {
], ],
}, },
plugins: [ plugins: [
new webpack.DllReferencePlugin({
context: process.cwd(),
manifest: require('../build/vendor/vendor.dll.json'),
}),
new ForkTsCheckerWebpackPlugin({ new ForkTsCheckerWebpackPlugin({
checkSyntacticErrors: true, checkSyntacticErrors: true,
}), }),
@ -158,9 +161,6 @@ module.exports = {
inject: 'body', inject: 'body',
favicon: 'assets/images/favicon.ico', favicon: 'assets/images/favicon.ico',
}), }),
new webpack.optimize.CommonsChunkPlugin({
names: ['vendor', 'manifest'],
}),
new webpack.DefinePlugin({ new webpack.DefinePlugin({
VERSION: JSON.stringify(require('../package.json').version), VERSION: JSON.stringify(require('../package.json').version),
}), }),

View File

@ -0,0 +1,30 @@
const path = require('path')
const webpack = require('webpack')
const packages = require('../package.json')
const dependencies = packages.dependencies
module.exports = {
node: {
fs: 'empty',
module: 'empty',
},
context: process.cwd(),
resolve: {
extensions: ['.js', '.jsx', '.json'],
modules: [__dirname, 'node_modules'],
},
entry: {
vendor: Object.keys(dependencies),
},
output: {
filename: '[name].dll.js',
path: path.resolve(__dirname, '../build/vendor'),
library: '[name]',
},
plugins: [
new webpack.DllPlugin({
name: '[name]',
path: './build/vendor/[name].dll.json',
}),
],
}