forked from msikka93/empmanagementui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.client.js
106 lines (98 loc) · 2.58 KB
/
webpack.client.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
104
105
106
'use strict'
const path = require('path')
const webpack = require('webpack')
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
const packageJson = require('./package.json')
const plugins = [
new MiniCssExtractPlugin({
// Options similar to the same options in webpackOptions.output
// both options are optional
filename: 'style.css'
}),
// define global vars
new webpack.DefinePlugin(
{
__CLIENT__: true,
__APPVERSION__: JSON.stringify(packageJson.version)
}
),
new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/),
new webpack.optimize.AggressiveMergingPlugin()
]
const optimization = {
splitChunks: {
cacheGroups: {
vendor: {
chunks: 'initial',
name: 'vendor',
test: 'vendor'
}
}
}
}
module.exports = {
// devtool: 'source-map',
// create a separte bundle for the modules which do not change very often
// so that is bundle is cached by the browser
entry: {
app: './src/client/index',
vendor: [
'react',
'redux',
'react-dom',
'react-router',
'react-intl'
]
},
output: {
path: path.join(__dirname, '/dist'),
filename: '[name].bundle.js'
},
module: {
rules: [
{
test: /\.(jsx|js)$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader'
}
},
// load styles
{
test: /\.less/,
use: [
MiniCssExtractPlugin.loader,
'css-loader',
{
loader: 'postcss-loader'
},
'less-loader'
]
},
{
test: /\.(scss|css)$/,
use: [
MiniCssExtractPlugin.loader,
'css-loader',
{
loader: 'postcss-loader'
},
'sass-loader']
},
// Load images
{ test: /\.jpg/, loader: 'url-loader?limit=10000&mimetype=image/jpg' },
{ test: /\.gif/, loader: 'url-loader?limit=10000&mimetype=image/gif' },
{ test: /\.png/, loader: 'url-loader?limit=10000&mimetype=image/png' },
{ test: /\.svg/, loader: 'url-loader?limit=10000&mimetype=image/svg' },
// Load fonts
{ test: /\.woff(\?v=[0-9]\.[0-9]\.[0-9])?$/, loader: 'url-loader?limit=10000&mimetype=application/font-woff' },
{ test: /\.(ttf|eot|svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/, loader: 'file-loader' },
{ test: /\.woff(2)?(\?v=\d+\.\d+\.\d+)?$/, loader: 'url-loader?limit=10000&mimetype=application/font-woff' }
]
},
plugins: plugins,
optimization: optimization,
resolve: {
extensions: ['.js', '.jsx', '.less', '.css', '.scss']
}
}