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>
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8"/>
<title>Chronograf</title>
</head>
<body>
<div id='react-root' data-basepath=""></div>
</body>
</html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<title>Chronograf</title>
</head>
<body>
<div id='react-root' data-basepath=""></div>
<script type="text/javascript" src="/vendor/vendor.dll.js"></script>
</body>
</body>
</html>

View File

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