-
Notifications
You must be signed in to change notification settings - Fork 1
/
webpack.common.js
86 lines (82 loc) · 1.79 KB
/
webpack.common.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
/* eslint-disable no-undef */
const path = require('path');
const DirectoryTreePlugin = require('directory-tree-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const { GenerateSW } = require('workbox-webpack-plugin');
const WebpackPwaManifest = require('webpack-pwa-manifest');
const inputPath = path.resolve(__dirname, 'src');
const outputPath = path.resolve(__dirname, 'dist');
module.exports = {
context: inputPath,
entry: {
'main': './main.tsx'
},
output: {
path: outputPath,
filename: '[name].js'
},
devServer: {
contentBase: outputPath,
watchContentBase: true,
disableHostCheck: true,
port: 9000,
proxy: {
'/experimental-admin/': {
target: 'https://experimental.vxm.pl',
secure: false,
changeOrigin: true
}
}
},
module: {
rules: [
{
test: /\.md$/,
use: [
'json-loader',
'front-matter-loader'
],
exclude: /node_modules/,
},
{
test: /\.(png|jpe?g|gif)$/i,
use: [
'file-loader'
]
},
{
test: /\.svg$/,
use: ['@svgr/webpack', 'file-loader'],
}
]
},
resolve: {
extensions: ['.tsx', '.ts', '.js']
},
plugins: [
new DirectoryTreePlugin({
dir: path.resolve(inputPath, 'experiments'),
path: path.resolve(inputPath, 'experiments.json'),
extensions: /\.md/
}),
new HtmlWebpackPlugin({
template: './index.html'
}),
new CleanWebpackPlugin(),
new GenerateSW({
maximumFileSizeToCacheInBytes: 500000000,
skipWaiting: true,
runtimeCaching: [{ handler: 'StaleWhileRevalidate', urlPattern: '.*' }]
}
),
new WebpackPwaManifest({
name: 'ExperiMental',
short_name: 'ExperiMental',
icons: [{
src: path.resolve(inputPath, 'resources/icon.svg'),
sizes: [256],
}]
})
]
};