-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
88 lines (86 loc) · 2.79 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
const path = require("path");
const webpack = require("webpack");
const HtmlWebpackPlugin = require('html-webpack-plugin');
const {
GenerateSW
} = require('workbox-webpack-plugin');
const CopyPlugin = require('copy-webpack-plugin');
const mode = process.env.NODE_ENV || 'development';
module.exports = function(env, args) {
return {
mode,
devtool: 'inline-source-map',
entry: './src/index.js',
output: {
filename: 'main.js',
path: path.resolve(__dirname, 'docs'),
clean: true
},
module: {
rules: [
{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
loader: "babel-loader",
options: { presets: ["@babel/env"] }
},
{
test: /\.css$/,
use: ["style-loader", "css-loader"]
}
]
},
resolve: {
extensions: ['*', '.js', '.jsx']
},
devServer: {
port: 3000,
compress: true,
static: {
directory: path.join(__dirname, 'public'),
},
},
plugins: [
new webpack.HotModuleReplacementPlugin(),
new webpack.DefinePlugin({
'build.mode': JSON.stringify(args.mode)
}),
new HtmlWebpackPlugin({
title: 'Corellon 🌙',
favicon: './public/assets/favicon.png',
template: './src/index.ejs',
meta: {
'mobile-web-app-capable': 'yes',
'apple-mobile-web-app-capable': 'yes',
'application-name': 'Corellon',
'apple-mobile-web-app-title': 'Corellon',
'theme-color': '#444444',
'msapplication-navbutton-color': '#444444',
'apple-mobile-web-app-status-bar-style': 'black-translucent',
'msapplication-starturl': '/corellon',
'viewport': 'width=device-width, initial-scale=1, shrink-to-fit=no'
}
}),
new CopyPlugin({
patterns: [{
from: './public/assets',
to: 'assets'
},
{
from: './public/manifest.json',
to: 'manifest.json'
}
]
}),
new GenerateSW({
mode,
clientsClaim: true,
skipWaiting: true,
runtimeCaching: [{
urlPattern: /\.js$/,
handler: 'NetworkFirst'
}]
}),
]
};
}