mirror of
https://github.com/aspnet/JavaScriptServices.git
synced 2025-12-22 17:47:53 +00:00
Change Angular2 template to use vendor DLL too. Temporarily disabled server-side prerendering.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import 'bootstrap/dist/css/bootstrap.css';
|
||||
import 'angular2/bundles/angular2-polyfills.js';
|
||||
import './styles/site.css';
|
||||
|
||||
import { bootstrap } from 'angular2/platform/browser';
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
ViewData["Title"] = "Home Page";
|
||||
}
|
||||
|
||||
<app asp-prerender-module="ClientApp/boot-server"
|
||||
asp-prerender-webpack-config="webpack.config.js">Loading...</app>
|
||||
<app>Loading...</app>
|
||||
|
||||
<script src="~/dist/vendor.js" asp-append-version="true"></script>
|
||||
@section scripts {
|
||||
<script src="~/dist/main.js" asp-append-version="true"></script>
|
||||
}
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
<body>
|
||||
@RenderBody()
|
||||
|
||||
<script src="~/dist/vendor.js" asp-append-version="true"></script>
|
||||
@RenderSection("scripts", required: false)
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -43,8 +43,11 @@
|
||||
"**.vspscc"
|
||||
],
|
||||
"scripts": {
|
||||
"prepublish": [
|
||||
"prepare": [
|
||||
"npm install",
|
||||
"webpack --config webpack.config.vendor.js"
|
||||
],
|
||||
"prepublish": [
|
||||
"webpack"
|
||||
]
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -2,7 +2,9 @@ var webpack = require('webpack');
|
||||
|
||||
module.exports = {
|
||||
plugins: [
|
||||
new webpack.optimize.OccurenceOrderPlugin(),
|
||||
new webpack.optimize.UglifyJsPlugin({
|
||||
compress: { warnings: false },
|
||||
minimize: true,
|
||||
mangle: false // Due to https://github.com/angular/angular/issues/6678
|
||||
})
|
||||
|
||||
40
templates/Angular2Spa/webpack.config.vendor.js
Normal file
40
templates/Angular2Spa/webpack.config.vendor.js
Normal file
@@ -0,0 +1,40 @@
|
||||
var path = require('path');
|
||||
var webpack = require('webpack');
|
||||
var ExtractTextPlugin = require('extract-text-webpack-plugin');
|
||||
var extractCSS = new ExtractTextPlugin('vendor.css');
|
||||
var isDevelopment = process.env.ASPNET_ENV === 'Development';
|
||||
|
||||
module.exports = {
|
||||
resolve: {
|
||||
extensions: [ '', '.js' ]
|
||||
},
|
||||
module: {
|
||||
loaders: [
|
||||
{ test: /\.(png|woff|woff2|eot|ttf|svg)$/, loader: 'url-loader?limit=100000' },
|
||||
{ test: /\.css/, loader: extractCSS.extract(['css']) }
|
||||
]
|
||||
},
|
||||
entry: {
|
||||
vendor: ['angular2/bundles/angular2-polyfills.js', 'bootstrap', 'bootstrap/dist/css/bootstrap.css', 'style-loader', 'jquery', 'angular2/core', 'angular2/common', 'angular2/http', 'angular2/router', 'angular2/platform/browser']
|
||||
},
|
||||
output: {
|
||||
path: path.join(__dirname, 'wwwroot', 'dist'),
|
||||
filename: '[name].js',
|
||||
library: '[name]_[hash]',
|
||||
},
|
||||
plugins: [
|
||||
extractCSS,
|
||||
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.DllPlugin({
|
||||
path: path.join(__dirname, 'wwwroot', 'dist', '[name]-manifest.json'),
|
||||
name: '[name]_[hash]'
|
||||
})
|
||||
].concat(isDevelopment ? [] : [
|
||||
new webpack.optimize.UglifyJsPlugin({
|
||||
compress: { warnings: false },
|
||||
minimize: true,
|
||||
mangle: true // Due to https://github.com/angular/angular/issues/6678
|
||||
})
|
||||
])
|
||||
};
|
||||
@@ -11,6 +11,6 @@ module.exports = {
|
||||
plugins: [
|
||||
extractCSS,
|
||||
new webpack.optimize.OccurenceOrderPlugin(),
|
||||
new webpack.optimize.UglifyJsPlugin({ minimize: true })
|
||||
new webpack.optimize.UglifyJsPlugin({ compress: { warnings: false } })
|
||||
]
|
||||
};
|
||||
|
||||
@@ -2,6 +2,7 @@ var path = require('path');
|
||||
var webpack = require('webpack');
|
||||
var ExtractTextPlugin = require('extract-text-webpack-plugin');
|
||||
var extractCSS = new ExtractTextPlugin('vendor.css');
|
||||
var isDevelopment = process.env.ASPNET_ENV === 'Development';
|
||||
|
||||
module.exports = {
|
||||
resolve: {
|
||||
@@ -29,5 +30,7 @@ module.exports = {
|
||||
path: path.join(__dirname, 'wwwroot', 'dist', '[name]-manifest.json'),
|
||||
name: '[name]_[hash]'
|
||||
})
|
||||
]
|
||||
].concat(isDevelopment ? [] : [
|
||||
new webpack.optimize.UglifyJsPlugin({ compress: { warnings: false } })
|
||||
])
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user