-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.js
More file actions
102 lines (101 loc) · 2.65 KB
/
webpack.config.js
File metadata and controls
102 lines (101 loc) · 2.65 KB
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
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const webpack = require('webpack');
const AddAssetHtmlWebpackPlugin = require('add-asset-html-webpack-plugin');
const WebpackPwaManifestPlugin = require('webpack-pwa-manifest');
const WorkboxWebpackPlugin = require('workbox-webpack-plugin');
module.exports = {
entry: {
bundle: path.resolve(__dirname, 'src/index.js'),
},
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'js/[name].[fullhash].js',
chunkFilename: 'js/[id].[chunkhash].js',
publicPath: 'https://cozy-place.vercel.app/',
},
resolve: {
extensions: ['.js'],
},
mode: 'production',
module: {
rules: [
{
test: /\.html$/,
use: 'html-loader',
},
{
test: /\.jpg|jpeg|png|svg$/,
use: {
loader: 'url-loader',
options: {
limit: 1000,
outputPath: 'assets/',
},
},
},
{
test: /\.js$/,
use: 'babel-loader',
exclude: /node_modules/,
},
],
},
plugins: [
new HtmlWebpackPlugin({
template: './public/index.html',
filename: './index.html',
}),
new webpack.DllReferencePlugin({
manifest: require('./modules-manifest.json'),
}),
new AddAssetHtmlWebpackPlugin({
filepath: path.resolve(__dirname, 'dist/js/*.dll.js'),
outputPath: 'js',
publicPath: 'https://cozy-place.vercel.app/js',
}),
new WebpackPwaManifestPlugin({
name: 'Cozy Place - Explore and Travel',
shotname: 'Cozy Place',
description:
'For decades travellers have reached for Lonely Planet books when looking to plan and execute their perfect trip, but now, they can also let Lonely Planet Experiences lead the way.',
background_color: '#F8F8F8',
theme_color: '#b1a',
start_url: '.',
icons: [
{
src: path.resolve('src/assets/icon.png'),
sizes: [96, 128, 192, 256, 384, 512],
purpose: 'any maskable',
},
],
}),
new WorkboxWebpackPlugin.GenerateSW({
runtimeCaching: [
{
urlPattern: new RegExp('https://cozy-place.vercel.app/'),
handler: 'StaleWhileRevalidate',
options: {
cacheName: 'images',
},
},
{
urlPattern: new RegExp(
'https://cozyplace.herokuapp.com/api/',
),
handler: 'NetworkFirst',
options: {
cacheName: 'api',
},
},
],
}),
],
optimization: {
splitChunks: {
name: 'commons',
minSize: 0,
chunks: 'all',
},
},
};