-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.dev.config.js
More file actions
91 lines (90 loc) · 2.26 KB
/
webpack.dev.config.js
File metadata and controls
91 lines (90 loc) · 2.26 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
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const webpack = require('webpack');
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: 'http://localhost:3000/',
},
resolve: {
extensions: ['.js'],
},
mode: 'development',
devServer: {
open: true,
hot: true,
port: 3000,
historyApiFallback: true,
},
module: {
rules: [
{
test: /\.html$/,
use: 'html-loader',
},
{
test: /\.jpg|jpeg|png|svg$/,
use: {
loader: 'file-loader',
options: {
outputPath: 'assets/',
},
},
},
{
test: /\.js$/,
use: 'babel-loader',
exclude: /node_modules/,
},
],
},
plugins: [
new HtmlWebpackPlugin({
template: './public/index.html',
}),
new webpack.HotModuleReplacementPlugin(),
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('http://localhost:3000/'),
handler: 'StaleWhileRevalidate',
options: {
cacheName: 'images',
},
},
{
urlPattern: new RegExp(
'https://cozyplace.herokuapp.com/api/',
),
handler: 'NetworkFirst',
options: {
cacheName: 'api',
},
},
],
}),
],
};