forked from cezerin/cezerin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.admin.js
114 lines (107 loc) · 2.85 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
const path = require('path');
const webpack = require('webpack');
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const HtmlWebpackPlugin = require('html-webpack-plugin');
const applicationConfig = require('./config/admin.js');
const applicationText = require('./locales/admin/' + 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: ['babel-loader']
}, {
test: /\.css$/,
include: [ path.resolve(__dirname, "public") ],
use: [
MiniCssExtractPlugin.loader,
{
loader: "css-loader",
options: {
modules: false,
importLoaders: true
}
}
]
}, {
test: /\.css$/,
exclude: /node_modules|public/,
use: [
MiniCssExtractPlugin.loader,
{
loader: "css-loader",
options: {
modules: true,
importLoaders: true,
localIdentName: "[name]__[local]___[hash:base64:5]"
}
}
]
}
]
},
plugins: [
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
})
]
};