-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
103 lines (97 loc) · 2.67 KB
/
webpack.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
const path = require('path');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const autoprefixer = require('autoprefixer');
const excludeUndefValues = require('./common/utils/excludeUndefValues');
const isProduction = process.env.NODE_ENV === 'production';
const styleConfig = ({ hashedClassNames = false, customLoaders = [] }) =>
ExtractTextPlugin.extract({
fallback: 'style-loader',
use: [
{
loader: 'css-loader',
options: excludeUndefValues({
minimize: isProduction,
sourceMap: true,
modules: hashedClassNames,
importLoaders: 1,
localIdentName: hashedClassNames
? '[folder]__[local]___[hash:base64:5]'
: undefined,
}),
},
{
loader: 'postcss-loader',
options: {
plugins: () =>
excludeUndefValues([
require('postcss-import')({}),
require('postcss-url')({ url: 'rebase' }),
hashedClassNames ? require('postcss-nested')({}) : undefined,
require('postcss-cssnext')({
browsers: [
// enable CSS properties which require prefixes
'> 1%',
'Firefox ESR',
'Opera 12.1',
'Android >= 4.4',
'iOS >= 8.0',
'Chrome >= 30', // equivalent to Android 4.4 WebView
'Safari >= 9',
],
}),
]),
},
},
].concat(customLoaders),
});
module.exports = {
entry: path.join(__dirname, '/client/src/app.js'),
output: {
path: path.join(__dirname, '/client/dist/bundles'),
filename: '[name].js',
},
module: {
rules: [
{
test: /\.js$/,
loader: 'babel-loader',
include: path.join(__dirname, '/client/src'),
},
{
test: /\.css$/,
use: styleConfig({}),
},
{
test: /\.less$/,
exclude: /antd\.less$/,
use: styleConfig({
hashedClassNames: true,
customLoaders: [
{
loader: 'less-loader',
options: {
javascriptEnabled: true,
},
},
],
}),
},
{
test: /antd\.less$/,
use: styleConfig({
hashedClassNames: false,
customLoaders: [
{
loader: 'less-loader',
options: {
javascriptEnabled: true,
},
},
],
}),
},
],
},
plugins: [new ExtractTextPlugin('[name].css')],
devtool: isProduction ? null : 'cheap-eval-source-map',
};