Permalink
Browse files

Split CSS away from the main bundle

  • Loading branch information...
lucapette committed Feb 17, 2017
1 parent e18700f commit 233eaecea4407b71fa97f8a55c6ac9b76119270b
Showing with 24 additions and 9 deletions.
  1. +1 −0 package.json
  2. +2 −3 public/index.html
  3. +10 −4 webpack.config.js
  4. +11 −2 yarn.lock
View
@@ -15,6 +15,7 @@
"babel-preset-es2015": "^6.22.0",
"babel-preset-react": "^6.22.0",
"css-loader": "^0.26.1",
+ "extract-text-webpack-plugin": "beta",
"flow-bin": "^0.38.0",
"react": "^15.4.2",
"react-dom": "^15.4.2",
View
@@ -2,9 +2,8 @@
<head>
</head>
<body>
- <div id="root">
- <!-- This div's content will be managed by React. Hopefully. -->
- </div>
+ <div id="root"></div>
<script src="/App.js" type="text/javascript"></script>
+ <link rel="stylesheet" href="/styles.css" type="text/css"/>
</body>
</html>
View
@@ -1,5 +1,7 @@
-var path = require("path");
-var webpack = require("webpack");
+const path = require("path");
+const webpack = require("webpack");
+
+const ExtractTextPlugin = require("extract-text-webpack-plugin");
const config = {
devtool: "#source-maps",
@@ -21,7 +23,10 @@ const config = {
},
{
test: /\.css$/,
- use: ["style-loader", "css-loader"]
+ use: ExtractTextPlugin.extract({
+ fallback: "style-loader",
+ use: "css-loader"
+ })
},
{
test: /\.(eot|woff|woff2|ttf|svg|png|jpg)$/,
@@ -32,7 +37,8 @@ const config = {
plugins: [
new webpack.ProvidePlugin({
'jQuery': 'jquery'
- })
+ }),
+ new ExtractTextPlugin('styles.css'),
],
devServer: {
contentBase: path.join(__dirname, "public")
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

0 comments on commit 233eaec

Please sign in to comment.