-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
41 lines (35 loc) · 925 Bytes
/
index.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
const ExtractTextPlugin = require('extract-text-webpack-plugin')
const cssLoaders = require('./css-loaders')
const ENV = process.env.NODE_ENV || 'development'
module.exports = ({ config }, {
minimize,
extractCSS,
filename = '[name].[contenthash:8].css',
sourceMap,
postcss = {},
cssModules,
autoprefixer,
externalLoaderOptions = {}
} = {}) => {
postcss.plugins = postcss.plugins || []
if (autoprefixer !== false) {
postcss.plugins.unshift(require('autoprefixer')(autoprefixer))
}
const cssOptions = {
minimize,
extract: extractCSS && ENV === 'production',
sourceMap: Boolean(sourceMap),
postcss,
cssModules,
externalLoaderOptions
}
// only use ExtractTextPlugin
if (extractCSS && ENV === 'production') {
config.plugin('extract-css')
.use(ExtractTextPlugin, [{
filename,
allChunks: true
}])
}
cssLoaders(config, cssOptions)
}