-
Notifications
You must be signed in to change notification settings - Fork 1
/
webpack.config.js
97 lines (86 loc) · 2.1 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
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const WebpackPwaManifest = require('webpack-pwa-manifest');
const workboxPlugin = require('workbox-webpack-plugin');
const FaviconsWebpackPlugin = require('favicons-webpack-plugin');
const pkg = require('./package.json');
const { isProd, envs, env } = require('./scripts/envs.js');
module.exports = {
entry: {
main: './src/index.js'
},
output: {
path: path.join(__dirname, './dist'),
filename: '[name].[hash].js',
chunkFilename: '[name].[hash].js'
},
mode: isProd() ? envs.production : envs.development ,
devtool: 'source-map',
plugins: [
new FaviconsWebpackPlugin('./src/assets/logo.png'),
new HtmlWebpackPlugin({
title: pkg.name,
description: pkg.description,
color: pkg.themeColor,
name: pkg.displayName,
template: './src/assets/index.html'
}),
new WebpackPwaManifest({
name: pkg.name,
short_name: pkg.displayName,
description: pkg.description,
background_color: '#ffffff',
theme_color: pkg.themeColor,
start_url: '',
icons: [
{
src: path.resolve('src/assets/logo.png'),
sizes: [96, 128, 192, 256, 384, 512] // multiple sizes
}
]
}),
new workboxPlugin.GenerateSW({
swDest: 'sw.js',
clientsClaim: true,
skipWaiting: true,
globPatterns: [
"**/*.{jpg,js,png,ico,json,html,css}"
],
})
],
resolve: {
extensions: ['.mjs', '.ts', '.js']
},
module: {
rules: [
{
test: /\.css$/,
use: ['style-loader', 'css-loader']
},
{
test: /\.scss$/,
use: [
'style-loader',
'css-loader',
'sass-loader']
},
{
test: /\.ts?$/,
use: 'ts-loader',
exclude: /node_modules/
},
{
test: /\.js?$/,
use: 'ts-loader',
exclude: /node_modules/
}
]
},
devServer: {
contentBase: path.join(__dirname, 'dist'),
compress: true,
port: 8080,
hot: true,
historyApiFallback: true
}
}