forked from okusnadi/cezerin2-admin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
152 lines (144 loc) · 3.09 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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
const path = require('path');
const webpack = require('webpack');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CleanWebpackPlugin = require('clean-webpack-plugin');
const applicationConfig = require('./config/admin.js');
const applicationText = require(`./locales/${applicationConfig.language}.json`);
const copyWebpackPlugin = require('copy-webpack-plugin');
module.exports = {
entry: {
app: path.resolve(__dirname, 'src/index.js'),
vendor: [
'react',
'react-dom',
'react-redux',
'redux-thunk',
'react-router-dom',
'react-dropzone',
'redux',
'redux-form',
'redux-form-material-ui',
'material-ui'
]
},
performance: {
hints: false
},
output: {
publicPath: '/',
path: path.resolve(__dirname, 'dist'),
filename: 'js/[name]-[chunkhash].js',
chunkFilename: 'js/[name]-[chunkhash].js'
},
optimization: {
splitChunks: {
cacheGroups: {
vendor: {
chunks: 'initial',
name: 'vendor',
test: 'vendor',
enforce: true
}
}
}
},
resolve: {
alias: {
src: path.resolve(__dirname, 'src'),
routes: path.resolve(__dirname, 'src/routes'),
modules: path.resolve(__dirname, 'src/modules'),
lib: path.resolve(__dirname, 'src/lib')
}
},
module: {
rules: [
{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: {
presets: ['env', 'react'],
plugins: ['transform-class-properties']
}
}
},
{
test: /\.css$/,
include: [path.resolve(__dirname, 'public')],
use: [
MiniCssExtractPlugin.loader,
{
loader: 'css-loader',
options: {
modules: false,
importLoaders: true
}
},
'postcss-loader'
]
},
{
test: /\.css$/,
exclude: /node_modules|public/,
use: [
MiniCssExtractPlugin.loader,
{
loader: 'css-loader',
options: {
modules: true,
importLoaders: true,
localIdentName: '[name]__[local]___[hash:base64:5]'
}
},
'postcss-loader'
]
}
]
},
plugins: [
new copyWebpackPlugin([
{
from: 'public',
to: 'assets'
}
]),
new CleanWebpackPlugin(
['dist/js/app-*.js', 'dist/js/vendor-*.js', 'dist/css/bundle-*.css'],
{ verbose: false }
),
new webpack.DefinePlugin({
APPLICATION_CONFIG: JSON.stringify(applicationConfig)
}),
new webpack.DefinePlugin({
APPLICATION_TEXT: JSON.stringify(applicationText)
}),
new MiniCssExtractPlugin({
filename: 'css/bundle-[contenthash].css',
chunkFilename: 'css/bundle-[contenthash].css'
}),
new HtmlWebpackPlugin({
template: 'src/index.html',
language: applicationConfig.language,
inject: 'body',
filename: 'index.html'
}),
new HtmlWebpackPlugin({
template: 'src/index.html',
language: applicationConfig.language,
inject: 'body',
filename: '404.html'
}),
new webpack.BannerPlugin({
banner: `Created: ${new Date().toUTCString()}`,
raw: false,
entryOnly: false
})
],
stats: {
children: false,
entrypoints: false,
modules: false
}
};