forked from skedwards88/monkeys
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
85 lines (78 loc) · 2.58 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
const path = require("path");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const WorkboxPlugin = require("workbox-webpack-plugin");
const FaviconsWebpackPlugin = require("favicons-webpack-plugin");
module.exports = (env, argv) => {
if (argv.mode === 'development') {
console.log('RUNNING IN DEV MODE. Service worker will not generate.')
} else {
console.log('RUNNING IN NON-DEV MODE. Service worker will generate.')
}
const htmlPlugin = new HtmlWebpackPlugin({
// Need to use template because need 'root' div for react injection. templateContent doesn't play nice with title, so just use a template file instead.
template: "./src/index.html",
})
const serviceWorkerPlugin = new WorkboxPlugin.GenerateSW({
// these options encourage the ServiceWorkers to get in there fast
// and not allow any straggling "old" SWs to hang around
clientsClaim: true,
skipWaiting: true,
})
const faviconPlugin = new FaviconsWebpackPlugin({
logo: "./src/images/favicon.png",
mode: "webapp", // optional can be 'webapp', 'light' or 'auto' - 'auto' by default
devMode: "webapp", // optional can be 'webapp' or 'light' - 'light' by default
favicons: {
appName: "Monkeys of the Caribbean",
short_name: "Monkeys",
start_url: "../.",
// scope: ".",
appDescription: "A spatial strategy game",
display: "standalone",
orientation: "landscape",
developerName: "skedwards88",
developerURL: null, // prevent retrieving from the nearest package.json
background: "#ece6a9",
theme_color: "#ece6a9",
icons: {
coast: false,
yandex: false,
},
},
})
const plugins = argv.mode === 'development' ? [htmlPlugin, faviconPlugin] : [htmlPlugin, faviconPlugin, serviceWorkerPlugin]
return {
entry: "./src/index.js",
mode: "production",
module: {
rules: [
{
test: /\.(js|jsx)$/,
exclude: /(node_modules|bower_components)/,
loader: "babel-loader",
options: { presets: ["@babel/env"] },
},
{
test: /\.css$/i,
use: ["style-loader", "css-loader"],
},
{
test: /\.(png|svg|jpg|jpeg|gif)$/i,
type: "asset/resource",
},
],
},
resolve: { extensions: ["*", ".js", ".jsx"] },
output: {
publicPath: "",
filename: "bundle.js",
path: path.resolve(__dirname, "dist"),
clean: true, // removes unused files from output dir
},
devServer: {
static: "./dist",
port: 4001,
},
plugins: plugins,
}
};