forked from oheyjesse/chicken-in
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
99 lines (98 loc) · 3.07 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
const path = require('path')
const webpack = require('webpack')
const UglifyJsPlugin = require('uglifyjs-webpack-plugin')
const BabiliPlugin = require('babili-webpack-plugin')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin
module.exports = (env) => {
const isProduction = env === 'production'
console.log('Production environment:', isProduction)
return {
entry: {
guestApp: ['babel-polyfill', './frontend/src/guestApp/index.js'],
employeeApp: ['babel-polyfill', './frontend/src/employeeApp/index.js'],
managerApp: ['babel-polyfill', './frontend/src/managerApp/index.js'],
},
// ['babel-polyfill', './frontend/src/guestView/index.js'],
output: {
path: path.resolve(__dirname, 'frontend', 'dist'),
filename: '[name]/js/bundle.js'
},
module: {
rules: [
{
loader: 'babel-loader',
test: /\.js$/,
exclude: /node_modules/
},
{
test: /\.(png|jpg|gif|svg)$/,
use: [
{
loader: 'file-loader',
options: {
name: '[name].[ext]',
outputPath: 'img/'
}
}
]
},
{
test: /\.s?css$/,
use: [
isProduction ? MiniCssExtractPlugin.loader : MiniCssExtractPlugin.loader, // 'style-loader'
{
loader: 'css-loader',
options: {
sourceMap: true
// minimize: true // This doesn't really do much
}
},
{
loader: 'sass-loader',
options: {
sourceMap: true
// minimize: true // This doesn't really do much
}
}
]
}
]
},
devServer: {
// contentBase: './frontend/dist/',
historyApiFallback: true
},
plugins: [
new HtmlWebpackPlugin({
filename: 'guestApp/index.html',
template: './frontend/src/guestApp/index.html',
chunks: ['guestApp']
}),
new HtmlWebpackPlugin({
filename: 'employeeApp/index.html',
template: './frontend/src/employeeApp/index.html',
chunks: ['employeeApp']
}),
new HtmlWebpackPlugin({
filename: 'managerApp/index.html',
template: './frontend/src/managerApp/index.html',
chunks: ['managerApp']
}),
new MiniCssExtractPlugin({
filename: '[name]/css/styles.css',
chunkFilename: '[name]/css/styles.css'
}),
new BundleAnalyzerPlugin(),
new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/) // Don't bundle locale files in moment. Saves almost 200kB
],
// optimization: {
// minimizer: [
// new UglifyJsPlugin(), // This doesn't really do much
// new BabiliPlugin() // This doesn't really do much
// ]
// },
devtool: isProduction ? 'source-map' : 'inline-source-map'
}
}