Skip to content

Commit 3a56782

Browse files
Extract CSS into a separate file so it can be loaded independently of JS execution
1 parent 2e9a43d commit 3a56782

File tree

3 files changed

+5
-1
lines changed

3 files changed

+5
-1
lines changed

samples/react/MusicStore/Views/Shared/_Layout.cshtml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
<head>
44
<meta charset="utf-8" />
55
<title>@ViewData["Title"]</title>
6+
<link rel="stylesheet" href="/dist/main.css" />
67
</head>
78
<body>
89
@RenderBody()

samples/react/MusicStore/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"babel-preset-react": "^6.3.13",
99
"css-loader": "^0.23.1",
1010
"express": "^4.13.4",
11+
"extract-text-webpack-plugin": "^1.0.1",
1112
"file-loader": "^0.8.5",
1213
"react-transform-hmr": "^1.0.2",
1314
"style-loader": "^0.13.0",

samples/react/MusicStore/webpack.config.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
var path = require('path');
22
var webpack = require('webpack');
3+
var ExtractTextPlugin = require('extract-text-webpack-plugin');
34

45
module.exports = {
56
devtool: 'inline-source-map',
@@ -10,7 +11,7 @@ module.exports = {
1011
loaders: [
1112
{ test: /\.ts(x?)$/, include: /ReactApp/, exclude: /node_modules/, loader: 'babel-loader' },
1213
{ test: /\.ts(x?)$/, include: /ReactApp/, exclude: /node_modules/, loader: 'ts-loader' },
13-
{ test: /\.css$/, loader: "style-loader!css-loader" },
14+
{ test: /\.css$/, loader: ExtractTextPlugin.extract('style-loader', 'css-loader') },
1415
{ test: /\.(png|woff|woff2|eot|ttf|svg)$/, loader: 'url-loader?limit=100000' }
1516
]
1617
},
@@ -25,6 +26,7 @@ module.exports = {
2526
},
2627
plugins: [
2728
new webpack.optimize.OccurenceOrderPlugin(),
29+
new ExtractTextPlugin('main.css'),
2830
new webpack.optimize.CommonsChunkPlugin('vendor', 'vendor.bundle.js') // Moves vendor content out of other bundles
2931
]
3032
};

0 commit comments

Comments
 (0)