Skip to content

Instantly share code, notes, and snippets.

@ChristopherBiscardi
Created January 20, 2016 19:02
Show Gist options
  • Save ChristopherBiscardi/e2df9fd9de035a206d56 to your computer and use it in GitHub Desktop.
Save ChristopherBiscardi/e2df9fd9de035a206d56 to your computer and use it in GitHub Desktop.
Extracting Stylesheets with Gatsby
var ExtractTextPlugin = require("extract-text-webpack-plugin");
module.exports = function(config, env) {
if(env === 'static') {
config.removeLoader('css');
config.loader('css', function(cfg) {
cfg.test = /\.css$/;
cfg.loader = ExtractTextPlugin.extract('css?minimize');
return cfg
})
config.plugin('extract-css',
ExtractTextPlugin,
["styles.css", { allChunks: true }]);
}
return config;
}
import './what.css';
...
<link rel="stylesheet" type="text/css" href='/styles.css'/>
  1. Install dependencies
npm install --save webpack extract-text-webpack-plugin
  1. Make the changes specified in the files here
body {
background: pink;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment