-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
executable file
·90 lines (89 loc) · 2.56 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
const path = require('path');
const webpack = require('webpack');
const HtmlWebpackPluin = require('html-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const Dotenv = require('dotenv-webpack');
const WebpackPwaManifest = require('webpack-pwa-manifest');
const WorkboxPlugin = require('workbox-webpack-plugin');
const PreloadWebpackPlugin = require('preload-webpack-plugin');
const env = require('dotenv').config();
module.exports = {
entry: './src/index.js',
output: {
path: path.join(__dirname, '/dist'),
filename: '[name].[contenthash].js',
publicPath:
env.parsed.REACT_APP_ENV === 'prod'
? env.parsed.REACT_APP_HOST + '/'
: '/'
},
resolve: {
alias: {
assets: path.resolve(__dirname, './src/assets/'),
components: path.resolve(__dirname, './src/components/'),
context: path.resolve(__dirname, './src/context/'),
reducer: path.resolve(__dirname, './src/reducer/'),
theme: path.resolve(__dirname, './src/theme/'),
types: path.resolve(__dirname, './src/types/'),
views: path.resolve(__dirname, './src/views/')
}
},
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader'
}
},
{
test: /\.scss$/,
use: ['style-loader', 'css-loader', 'sass-loader']
}
]
},
devServer: {
contentBase: './dist'
},
optimization: {
minimize: true
},
plugins: [
new webpack.NormalModuleReplacementPlugin(
/@material-ui\/lab\/esm\/Autocomplete\/Autocomplete\.js/,
'../../../../../src/components/Autocomplete/Autocomplete.js'
),
new HtmlWebpackPluin({
favicon: './public/favicon.ico',
template: './public/index.html',
filename:
env.parsed.REACT_APP_ENV === 'prod' ? 'app.blade.php' : 'index.html'
}),
new PreloadWebpackPlugin(),
new WebpackPwaManifest({
fingerprints: false,
display: 'standalone',
name: env.parsed.RESTAURANT_NAME,
short_name: env.parsed.RESTAURANT_SHORT_NAME,
start_url: '/',
theme_color: env.parsed.RESTAURANT_THEME_COLOR,
background_color: env.parsed.RESTAURANT_BACKGROUND_COLOR,
icons: [
{
src: path.resolve('public/icon.png'),
sizes: [96, 128, 192, 256, 256, 512]
}
]
}),
new MiniCssExtractPlugin({
filename: '[name].css',
chunkFilename: '[id].css'
}),
new Dotenv(),
new WorkboxPlugin.GenerateSW({
clientsClaim: true,
skipWaiting: true
})
]
};