Change Angular2 template to use vendor DLL too. Temporarily disabled server-side prerendering.

This commit is contained in:
SteveSandersonMS
2016-03-01 14:30:42 +00:00
parent 2c3f29df11
commit 4dcf63dab4
9 changed files with 62 additions and 19 deletions

View File

@@ -2,8 +2,7 @@ var path = require('path');
var webpack = require('webpack');
var merge = require('extendify')({ isDeep: true, arrays: 'concat' });
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var extractSiteCSS = new ExtractTextPlugin('styles.css');
var extractVendorCSS = new ExtractTextPlugin('vendor.css');
var extractCSS = new ExtractTextPlugin('styles.css');
var devConfig = require('./webpack.config.dev');
var prodConfig = require('./webpack.config.prod');
var isDevelopment = process.env.ASPNET_ENV === 'Development';
@@ -15,15 +14,12 @@ module.exports = merge({
module: {
loaders: [
{ test: /\.ts$/, include: /ClientApp/, loader: 'ts-loader' },
{ test: /\.(png|woff|woff2|eot|ttf|svg)$/, loader: 'url-loader?limit=100000' },
{ test: /\.html$/, loader: 'raw-loader' },
{ test: /\.css/, include: /bootstrap/, loader: extractVendorCSS.extract(['css']) },
{ test: /\.css/, exclude: /bootstrap/, loader: extractSiteCSS.extract(['css']) },
{ test: /\.css/, loader: extractCSS.extract(['css']) }
]
},
entry: {
main: ['./ClientApp/boot-client.ts'],
vendor: ['angular2/bundles/angular2-polyfills.js', 'bootstrap', 'style-loader', 'jquery', 'angular2/core', 'angular2/common', 'angular2/http', 'angular2/router', 'angular2/platform/browser']
main: ['./ClientApp/boot-client.ts']
},
output: {
path: path.join(__dirname, 'wwwroot', 'dist'),
@@ -31,10 +27,10 @@ module.exports = merge({
publicPath: '/dist/'
},
plugins: [
new webpack.ProvidePlugin({ $: 'jquery', jQuery: 'jquery' }), // Maps these identifiers to the jQuery package (because Bootstrap expects it to be a global variable)
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.optimize.CommonsChunkPlugin('vendor', 'vendor.js'), // Moves vendor content out of other bundles
extractSiteCSS,
extractVendorCSS
extractCSS,
new webpack.DllReferencePlugin({
context: __dirname,
manifest: require('./wwwroot/dist/vendor-manifest.json')
})
]
}, isDevelopment ? devConfig : prodConfig);