forked from 418sec/cezerin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.admin.js
143 lines (135 loc) · 3.01 KB
/
webpack.config.admin.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
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`);
module.exports = {
entry: {
app: path.resolve(__dirname, 'src/admin/client/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, 'public'),
filename: 'admin-assets/js/[name]-[chunkhash].js',
chunkFilename: 'admin-assets/js/[name]-[chunkhash].js'
},
optimization: {
splitChunks: {
cacheGroups: {
vendor: {
chunks: 'initial',
name: 'vendor',
test: 'vendor',
enforce: true
}
}
}
},
resolve: {
alias: {
src: path.resolve(__dirname, 'src/admin/client'),
routes: path.resolve(__dirname, 'src/admin/client/routes'),
modules: path.resolve(__dirname, 'src/admin/client/modules'),
lib: path.resolve(__dirname, 'src/admin/client/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 CleanWebpackPlugin(
[
'public/admin-assets/js/app-*.js',
'public/admin-assets/js/vendor-*.js',
'public/admin-assets/css/bundle-*.css'
],
{ verbose: false }
),
new webpack.DefinePlugin({
APPLICATION_CONFIG: JSON.stringify(applicationConfig)
}),
new webpack.DefinePlugin({
APPLICATION_TEXT: JSON.stringify(applicationText)
}),
new MiniCssExtractPlugin({
filename: 'admin-assets/css/bundle-[contenthash].css',
chunkFilename: 'admin-assets/css/bundle-[contenthash].css'
}),
new HtmlWebpackPlugin({
template: 'src/admin/client/index.html',
language: applicationConfig.language,
inject: 'body',
filename: 'admin/index.html'
}),
new webpack.BannerPlugin({
banner: `Created: ${new Date().toUTCString()}`,
raw: false,
entryOnly: false
})
],
stats: {
children: false,
entrypoints: false,
modules: false
}
};