rickvanlieshout.com/gatsby.config.js

54 lines
1.5 KiB
JavaScript
Raw Normal View History

2016-03-11 23:28:19 +01:00
import webpack from 'webpack'
import precss from 'precss'
import lost from 'lost'
import rucksack from 'rucksack-css'
import ExtractTextPlugin from 'extract-text-webpack-plugin'
module.exports = function(config, env) {
var is_static = env === 'static';
var is_develop = env === 'develop';
var is_production = env === 'production';
config.merge({
2016-03-21 18:03:01 +01:00
postcss: [
lost(),
rucksack({
autoprefixer: true
})
]
2016-03-11 23:28:19 +01:00
});
config.removeLoader('css');
if (is_develop) {
2016-03-21 18:03:01 +01:00
config.loader('css', function(cfg) {
cfg.test = /\.css/;
cfg.loaders = ['style', 'css-loader', 'postcss-loader'];
return cfg
})
config.loader('postcss', function(cfg) {
cfg.test = /\.sss/;
cfg.loaders = ['style', 'css-loader', 'postcss-loader?parser=sugarss'];
return cfg
})
2016-03-11 23:28:19 +01:00
} else {
2016-03-21 18:03:01 +01:00
config.loader('css', function(cfg) {
cfg.test = /\.css/;
cfg.loader = ExtractTextPlugin.extract(['css-loader', 'postcss-loader']);
return cfg
})
config.loader('postcss', function(cfg) {
cfg.test = /\.sss/;
cfg.loader = ExtractTextPlugin.extract(['css-loader', 'postcss-loader?parser=sugarss']);
return cfg
})
2016-03-11 23:28:19 +01:00
}
2016-03-21 18:03:01 +01:00
2016-03-11 23:28:19 +01:00
config.plugin('extract-css',
2016-03-21 18:03:01 +01:00
ExtractTextPlugin,
["styles.css", {
allChunks: true
}]);
2016-03-11 23:28:19 +01:00
2016-03-21 18:03:01 +01:00
return config
2016-03-11 23:28:19 +01:00
};