mirror of
https://github.com/aspnet/JavaScriptServices.git
synced 2025-12-22 17:47:53 +00:00
In Angular 2 template, always load CSS via ExtractTextPlugin (otherwise you get a bad FOUC when loading server-prerendered page)
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import 'bootstrap/dist/css/bootstrap.css';
|
||||
import './styles/site.css';
|
||||
|
||||
import { bootstrap } from 'angular2/platform/browser';
|
||||
import { FormBuilder } from 'angular2/common';
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
@media (max-width: 767px) {
|
||||
/* On small screens, the nav menu spans the full width of the screen. Leave a space for it. */
|
||||
.body-content {
|
||||
padding-top: 50px;
|
||||
}
|
||||
}
|
||||
@@ -16,7 +16,6 @@ import { Counter } from '../counter/counter';
|
||||
])
|
||||
@ng.View({
|
||||
template: require('./app.html'),
|
||||
styles: [require('./app.css')],
|
||||
directives: [NavMenu, router.ROUTER_DIRECTIVES]
|
||||
})
|
||||
export class App {
|
||||
|
||||
@@ -6,8 +6,7 @@ import * as router from 'angular2/router';
|
||||
})
|
||||
@ng.View({
|
||||
template: require('./nav-menu.html'),
|
||||
directives: [router.ROUTER_DIRECTIVES],
|
||||
styles: [require('./nav-menu.css')]
|
||||
directives: [router.ROUTER_DIRECTIVES]
|
||||
})
|
||||
export class NavMenu {
|
||||
}
|
||||
|
||||
@@ -1,3 +1,10 @@
|
||||
@media (max-width: 767px) {
|
||||
/* On small screens, the nav menu spans the full width of the screen. Leave a space for it. */
|
||||
.body-content {
|
||||
padding-top: 50px;
|
||||
}
|
||||
}
|
||||
|
||||
.main-nav li .glyphicon {
|
||||
margin-right: 10px;
|
||||
}
|
||||
@@ -10,7 +17,6 @@
|
||||
color: white;
|
||||
}
|
||||
|
||||
|
||||
/* Keep the nav menu independent of scrolling and on top of other items */
|
||||
.main-nav {
|
||||
position: fixed;
|
||||
@@ -5,10 +5,8 @@
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>@ViewData["Title"] - WebApplicationBasic</title>
|
||||
<base href="/" />
|
||||
|
||||
<environment names="Staging,Production">
|
||||
<link rel="stylesheet" href="~/dist/site.css" />
|
||||
</environment>
|
||||
<link rel="stylesheet" href="~/dist/vendor.css" asp-append-version="true" />
|
||||
<link rel="stylesheet" href="~/dist/styles.css" asp-append-version="true" />
|
||||
</head>
|
||||
<body>
|
||||
@RenderBody()
|
||||
|
||||
@@ -1,8 +1,3 @@
|
||||
module.exports = {
|
||||
devtool: 'inline-source-map',
|
||||
module: {
|
||||
loaders: [
|
||||
{ test: /\.css/, exclude: /ClientApp/, loader: 'style!css' }
|
||||
]
|
||||
}
|
||||
devtool: 'inline-source-map'
|
||||
};
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
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 devConfig = require('./webpack.config.dev');
|
||||
var prodConfig = require('./webpack.config.prod');
|
||||
var isDevelopment = process.env.ASPNET_ENV === 'Development';
|
||||
@@ -13,13 +16,14 @@ module.exports = merge({
|
||||
loaders: [
|
||||
{ test: /\.ts$/, include: /ClientApp/, loader: 'ts-loader' },
|
||||
{ test: /\.(png|woff|woff2|eot|ttf|svg)$/, loader: 'url-loader?limit=100000' },
|
||||
{ test: /\.css$/, include: /ClientApp/, loader: 'raw-loader' },
|
||||
{ test: /\.html$/, loader: 'raw-loader' }
|
||||
{ test: /\.html$/, loader: 'raw-loader' },
|
||||
{ test: /\.css/, include: /bootstrap/, loader: extractVendorCSS.extract(['css']) },
|
||||
{ test: /\.css/, exclude: /bootstrap/, loader: extractSiteCSS.extract(['css']) },
|
||||
]
|
||||
},
|
||||
entry: {
|
||||
main: ['./ClientApp/boot-client.ts'],
|
||||
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']
|
||||
vendor: ['angular2/bundles/angular2-polyfills.js', 'bootstrap', 'style-loader', 'jquery', 'angular2/core', 'angular2/common', 'angular2/http', 'angular2/router', 'angular2/platform/browser']
|
||||
},
|
||||
output: {
|
||||
path: path.join(__dirname, 'wwwroot', 'dist'),
|
||||
@@ -29,6 +33,8 @@ module.exports = merge({
|
||||
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
|
||||
new webpack.optimize.CommonsChunkPlugin('vendor', 'vendor.js'), // Moves vendor content out of other bundles
|
||||
extractSiteCSS,
|
||||
extractVendorCSS
|
||||
]
|
||||
}, isDevelopment ? devConfig : prodConfig);
|
||||
|
||||
@@ -1,15 +1,7 @@
|
||||
var webpack = require('webpack');
|
||||
var ExtractTextPlugin = require('extract-text-webpack-plugin');
|
||||
var extractCSS = new ExtractTextPlugin('site.css');
|
||||
|
||||
module.exports = {
|
||||
module: {
|
||||
loaders: [
|
||||
{ test: /\.css/, exclude: /ClientApp/, loader: extractCSS.extract(['css']) },
|
||||
]
|
||||
},
|
||||
plugins: [
|
||||
extractCSS,
|
||||
new webpack.optimize.UglifyJsPlugin({
|
||||
minimize: true,
|
||||
mangle: false // Due to https://github.com/angular/angular/issues/6678
|
||||
|
||||
Reference in New Issue
Block a user