Skip to content

Commit

Permalink
Load CSS as a separate file
Browse files Browse the repository at this point in the history
This prevents FOUC when loading at the cost of an extra request.
  • Loading branch information
yuvipanda committed Dec 20, 2017
1 parent 79a97c8 commit 8996701
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
1 change: 1 addition & 0 deletions binderhub/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
{% block head %}
<meta id="base-url" data-url="{{base_url}}">
<script src="{{static_url("dist/bundle.js")}}"></script>
<link href="{{static_url("dist/styles.css")}}" rel="stylesheet"></link>
{{ super() }}
<script>
{% if submit %} window.submitBuild = true; {% endif %}
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"devDependencies": {
"bootstrap": "^3.3.7",
"css-loader": "^0.28.7",
"extract-text-webpack-plugin": "^3.0.2",
"file-loader": "^1.1.6",
"jquery": "^3.2.1",
"style-loader": "^0.19.1",
Expand Down
11 changes: 8 additions & 3 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
var webpack = require('webpack');
const webpack = require('webpack');
const ExtractTextPlugin = require("extract-text-webpack-plugin");

module.exports = {
context: __dirname + "/binderhub/static/",
Expand All @@ -12,7 +13,10 @@ module.exports = {
rules: [
{
test: /\.css$/,
use: [ 'style-loader', 'css-loader' ]
use: ExtractTextPlugin.extract({
fallback: "style-loader",
use: "css-loader"
})
},
{
test: /\.(eot|woff|ttf|woff2|svg)$/,
Expand All @@ -25,6 +29,7 @@ module.exports = {
new webpack.ProvidePlugin({
$: 'jquery',
jQuery: 'jquery',
})
}),
new ExtractTextPlugin("styles.css"),
]
}

0 comments on commit 8996701

Please sign in to comment.