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 './styles/site.css';
|
||||||
|
|
||||||
import { bootstrap } from 'angular2/platform/browser';
|
import { bootstrap } from 'angular2/platform/browser';
|
||||||
|
|||||||
@@ -2,9 +2,9 @@
|
|||||||
ViewData["Title"] = "Home Page";
|
ViewData["Title"] = "Home Page";
|
||||||
}
|
}
|
||||||
|
|
||||||
<app asp-prerender-module="ClientApp/boot-server"
|
<app>Loading...</app>
|
||||||
asp-prerender-webpack-config="webpack.config.js">Loading...</app>
|
|
||||||
|
|
||||||
|
<script src="~/dist/vendor.js" asp-append-version="true"></script>
|
||||||
@section scripts {
|
@section scripts {
|
||||||
<script src="~/dist/main.js" asp-append-version="true"></script>
|
<script src="~/dist/main.js" asp-append-version="true"></script>
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,6 @@
|
|||||||
<body>
|
<body>
|
||||||
@RenderBody()
|
@RenderBody()
|
||||||
|
|
||||||
<script src="~/dist/vendor.js" asp-append-version="true"></script>
|
|
||||||
@RenderSection("scripts", required: false)
|
@RenderSection("scripts", required: false)
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -43,8 +43,11 @@
|
|||||||
"**.vspscc"
|
"**.vspscc"
|
||||||
],
|
],
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"prepublish": [
|
"prepare": [
|
||||||
"npm install",
|
"npm install",
|
||||||
|
"webpack --config webpack.config.vendor.js"
|
||||||
|
],
|
||||||
|
"prepublish": [
|
||||||
"webpack"
|
"webpack"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,8 +2,7 @@ var path = require('path');
|
|||||||
var webpack = require('webpack');
|
var webpack = require('webpack');
|
||||||
var merge = require('extendify')({ isDeep: true, arrays: 'concat' });
|
var merge = require('extendify')({ isDeep: true, arrays: 'concat' });
|
||||||
var ExtractTextPlugin = require('extract-text-webpack-plugin');
|
var ExtractTextPlugin = require('extract-text-webpack-plugin');
|
||||||
var extractSiteCSS = new ExtractTextPlugin('styles.css');
|
var extractCSS = new ExtractTextPlugin('styles.css');
|
||||||
var extractVendorCSS = new ExtractTextPlugin('vendor.css');
|
|
||||||
var devConfig = require('./webpack.config.dev');
|
var devConfig = require('./webpack.config.dev');
|
||||||
var prodConfig = require('./webpack.config.prod');
|
var prodConfig = require('./webpack.config.prod');
|
||||||
var isDevelopment = process.env.ASPNET_ENV === 'Development';
|
var isDevelopment = process.env.ASPNET_ENV === 'Development';
|
||||||
@@ -15,15 +14,12 @@ module.exports = merge({
|
|||||||
module: {
|
module: {
|
||||||
loaders: [
|
loaders: [
|
||||||
{ test: /\.ts$/, include: /ClientApp/, loader: 'ts-loader' },
|
{ 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: /\.html$/, loader: 'raw-loader' },
|
||||||
{ test: /\.css/, include: /bootstrap/, loader: extractVendorCSS.extract(['css']) },
|
{ test: /\.css/, loader: extractCSS.extract(['css']) }
|
||||||
{ test: /\.css/, exclude: /bootstrap/, loader: extractSiteCSS.extract(['css']) },
|
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
entry: {
|
entry: {
|
||||||
main: ['./ClientApp/boot-client.ts'],
|
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']
|
|
||||||
},
|
},
|
||||||
output: {
|
output: {
|
||||||
path: path.join(__dirname, 'wwwroot', 'dist'),
|
path: path.join(__dirname, 'wwwroot', 'dist'),
|
||||||
@@ -31,10 +27,10 @@ module.exports = merge({
|
|||||||
publicPath: '/dist/'
|
publicPath: '/dist/'
|
||||||
},
|
},
|
||||||
plugins: [
|
plugins: [
|
||||||
new webpack.ProvidePlugin({ $: 'jquery', jQuery: 'jquery' }), // Maps these identifiers to the jQuery package (because Bootstrap expects it to be a global variable)
|
extractCSS,
|
||||||
new webpack.optimize.OccurenceOrderPlugin(),
|
new webpack.DllReferencePlugin({
|
||||||
new webpack.optimize.CommonsChunkPlugin('vendor', 'vendor.js'), // Moves vendor content out of other bundles
|
context: __dirname,
|
||||||
extractSiteCSS,
|
manifest: require('./wwwroot/dist/vendor-manifest.json')
|
||||||
extractVendorCSS
|
})
|
||||||
]
|
]
|
||||||
}, isDevelopment ? devConfig : prodConfig);
|
}, isDevelopment ? devConfig : prodConfig);
|
||||||
|
|||||||
@@ -2,7 +2,9 @@ var webpack = require('webpack');
|
|||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
plugins: [
|
plugins: [
|
||||||
|
new webpack.optimize.OccurenceOrderPlugin(),
|
||||||
new webpack.optimize.UglifyJsPlugin({
|
new webpack.optimize.UglifyJsPlugin({
|
||||||
|
compress: { warnings: false },
|
||||||
minimize: true,
|
minimize: true,
|
||||||
mangle: false // Due to https://github.com/angular/angular/issues/6678
|
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: [
|
plugins: [
|
||||||
extractCSS,
|
extractCSS,
|
||||||
new webpack.optimize.OccurenceOrderPlugin(),
|
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 webpack = require('webpack');
|
||||||
var ExtractTextPlugin = require('extract-text-webpack-plugin');
|
var ExtractTextPlugin = require('extract-text-webpack-plugin');
|
||||||
var extractCSS = new ExtractTextPlugin('vendor.css');
|
var extractCSS = new ExtractTextPlugin('vendor.css');
|
||||||
|
var isDevelopment = process.env.ASPNET_ENV === 'Development';
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
resolve: {
|
resolve: {
|
||||||
@@ -29,5 +30,7 @@ module.exports = {
|
|||||||
path: path.join(__dirname, 'wwwroot', 'dist', '[name]-manifest.json'),
|
path: path.join(__dirname, 'wwwroot', 'dist', '[name]-manifest.json'),
|
||||||
name: '[name]_[hash]'
|
name: '[name]_[hash]'
|
||||||
})
|
})
|
||||||
]
|
].concat(isDevelopment ? [] : [
|
||||||
|
new webpack.optimize.UglifyJsPlugin({ compress: { warnings: false } })
|
||||||
|
])
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user