-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.babel.js
98 lines (92 loc) · 2.02 KB
/
webpack.config.babel.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
import path from 'path';
import HtmlWebpackPlugin from 'html-webpack-plugin';
import WebpackPwaManifest from 'webpack-pwa-manifest';
import CopyWebpackPlugin from 'copy-webpack-plugin';
import CleanWebpackPlugin from 'clean-webpack-plugin';
import WorkboxPlugin from 'workbox-webpack-plugin';
const port = process.env.PORT || 5000;
module.exports = {
entry: './src/app.js',
output: {
filename: 'bundle.js',
path: path.resolve(__dirname, 'dist'),
},
module: {
rules: [
{
test: /\.(js)$/,
exclude: /node_modules/,
use: [ 'babel-loader' ],
},
{
test: /\.css$/,
use: [
{
loader: 'style-loader',
},
{
loader: 'css-loader',
options: {
modules: true,
camelCase: true,
sourceMap: true,
},
},
],
},
],
},
plugins: [
new CleanWebpackPlugin([ 'dist' ]),
new HtmlWebpackPlugin({
title: 'PRWP',
meta: { viewport: 'width=device-width, initial-scale=1, shrink-to-fit=no' },
}),
new CopyWebpackPlugin([
{
from: 'node_modules/idb/lib/idb.js', to: 'db',
},
{
from: 'src/db/index.js', to: 'db',
}
]),
new WebpackPwaManifest({
name: 'PRWP',
short_name: 'PRWP',
description: 'Progressive React Web App Starter Kit',
background_color: '#ffffff',
gcm_sender_id: '',
orientation: "portrait",
display: "standalone",
start_url: ".",
inject: true,
fingerprints: true,
ios: false,
publicPath: null,
includeDirectory: true,
icons: [
{
src: path.resolve('src/assets/images/icon.png'),
destination: path.join('icons'),
sizes: [ 96, 128, 192, 256, 384, 512 ],
},
{
src: path.resolve('src/assets/images/large-icon.png'),
destination: path.join('icons'),
size: '1024x1024',
},
],
}),
new WorkboxPlugin.InjectManifest({
swSrc: './src/pwa/service-worker.js',
swDest: './service-worker.js',
importScripts: [ 'db/index.js', 'db/idb.js' ],
}),
],
devServer: {
host: 'localhost',
port: port,
historyApiFallback: true,
open: true,
},
};