-
Notifications
You must be signed in to change notification settings - Fork 9
/
webpack.config.js
172 lines (169 loc) · 6.17 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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
const path = require('path');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin');
const ImageminPlugin = require('imagemin-webpack-plugin').default;
const VueLoaderPlugin = require("vue-loader/lib/plugin");
const WorkboxWebpackPlugin = require('workbox-webpack-plugin');
const TerserPlugin = require('terser-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const WebpackPwaManifest = require('webpack-pwa-manifest');
const publicPath = process.argv[process.argv.indexOf('--mode') + 1] === 'production' ? 'https://ukeloop.github.io/gk6x_gui/' : '/';
module.exports = [
{
entry: {
app: [
'./src/js/index.js',
'./src/sass/style.scss',
],
},
output: {
path: path.resolve(__dirname, 'docs'),
filename: 'assets/js/[name].js?v=[hash]',
publicPath: publicPath,
},
devServer: {
contentBase: path.resolve(__dirname, 'docs'),
watchContentBase: true,
port: 3000,
open: true,
},
module: {
rules: [
{
test: /\.vue$/,
loader: "vue-loader",
},
{
test: /\.js$/,
exclude: /node_modules/,
loader: 'babel-loader',
},
{
test: /\.scss$/,
use: [
{
loader: MiniCssExtractPlugin.loader,
},
{
loader: 'css-loader',
},
{
loader: 'postcss-loader',
options: {
ident: 'postcss',
plugins: [
require('tailwindcss'),
],
},
},
{
loader: 'sass-loader',
}
],
},
{
test: /\.json$/,
loader: "json-loader",
type: "javascript/auto"
},
{
test: /\.(jpe?g|png|gif|woff|woff2|eot|ttf|svg)$/,
use: [
{
loader: 'url-loader?limit=100000&name=images/[name].[ext]?v=[hash]',
},
],
},
],
},
optimization: {
minimize: true,
minimizer: [
new OptimizeCSSAssetsPlugin(),
new TerserPlugin()
],
splitChunks: {
name: 'vendor',
chunks: 'initial',
}
},
resolve: {
extensions: ['.js', '.vue'],
alias: {
"vue": "vue/dist/vue.esm.js"
},
},
plugins: [
new HtmlWebpackPlugin({
template: path.resolve(__dirname, 'src/index.html'),
title: 'GK6X GUI',
meta: {
viewport: 'width=device-width,initial-scale=1',
description: 'Configure keys on GK6X keyboards (GK64, GK84, GK61, etc) - GK6X GUI',
'og:title': 'GK6X GUI',
'og:type': 'website',
'og:url': publicPath,
'og:image': publicPath + 'assets/images/ogp.png',
'og:site_name': 'GK6X GUI',
'og:description': 'Configure keys on GK6X keyboards (GK64, GK84, GK61, etc) - GK6X GUI',
'og:locale': 'en_US',
'twitter:card': 'summary',
},
favicon: path.resolve(__dirname, 'src/favicon.ico'),
minify: {
collapseWhitespace: true,
removeComments: true,
removeRedundantAttributes: true,
removeScriptTypeAttributes: true,
removeStyleLinkTypeAttributes: true,
useShortDoctype: true
},
}),
new WebpackPwaManifest({
filename: "[name].[ext]",
name: "GK6X GUI",
short_name: "GK6X GUI",
description: "Configure keys on GK6X keyboards (GK64, GK84, GK61, etc) - GK6X GUI",
background_color: "#262626",
theme_color: "#262626",
start_url: publicPath + "?utm_source=homescreen",
display: "standalone",
orientation: "any",
lang: "English",
publicPath: publicPath,
fingerprints: false,
ios: true,
icons: [
{
src: path.resolve(__dirname, 'src/images/icon.png'),
sizes: [96, 128, 192, 256, 384, 512],
destination: '/assets/images/icons/ios',
ios: true
}
],
}),
new VueLoaderPlugin(),
new CopyWebpackPlugin([
{
from: path.resolve(__dirname, 'src/images/'),
to: path.resolve(__dirname, 'docs/assets/images/'),
},
]),
new ImageminPlugin({
test: /\.(jpe?g|png|gif|svg)$/i,
pngquant: {
quality: '95-100',
},
}),
new MiniCssExtractPlugin({
filename: 'assets/css/style.css?v=[hash]',
}),
new WorkboxWebpackPlugin.InjectManifest({
swSrc: path.resolve(__dirname, 'src/sw.js'),
swDest: path.resolve(__dirname, 'docs/sw.js'),
exclude: [/\.DS*/],
}),
],
},
];