-
Notifications
You must be signed in to change notification settings - Fork 6
/
gatsby.config.js
41 lines (40 loc) · 1.14 KB
/
gatsby.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
var path = require('path')
var ExtractTextPlugin = require('extract-text-webpack-plugin')
module.exports = function (config, env) {
config.merge({
resolveLoader: {
alias: {
markdown: path.join(__dirname, './loaders/markdown')
}
}
})
config.loader('js', function (cfg) {
cfg.loaders.unshift('atomic-loader?configPath=' + __dirname + '/atomicCssConfig.js')
return cfg
})
config.loader('css', function (cfg) {
cfg.loaders.push('autoprefixer?browsers=last 2 versions')
return cfg
})
config.loader('font', function (cfg) {
cfg.test = /\.(ttf|eot|svg|woff(2)?)(\?[a-z0-9]+)?$/
cfg.loader = 'file-loader?name=fonts/[name].[ext]'
return cfg
})
if (env === 'production') {
config.removeLoader('css')
config.loader('css', function (cfg) {
cfg.test = /\.css$/
cfg.loader = ExtractTextPlugin.extract(
'style-loader',
'css-loader?safe',
'autoprefixer-loader?browsers=last 2 versions'
)
return cfg
})
config.plugin('extract-css',
ExtractTextPlugin,
['bundle.css', { allChunks: true }])
}
return config
}