-
Notifications
You must be signed in to change notification settings - Fork 8
/
dev-config.ts
34 lines (30 loc) · 925 Bytes
/
dev-config.ts
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
const getWebappWebpackPlugin = (config) => `new WebappWebpackPlugin({
logo: './${config.favPath}',
favicons: {
appName: '${config.manifestDetails.shortName}',
appDescription: '${config.manifestDetails.description}',
start_url: '${config.manifestDetails.startURL}',
theme_color: '${config.manifestDetails.themeColor}'
}
})`;
const getSwDetails = () => `new GenerateSW({
clientsClaim: true,
skipWaiting: true,
runtimeCaching: [{
urlPattern: /\\/\$/,
handler: 'networkFirst',
options: {
cacheName: 'sw-app-index'
}
}]
})`;
export default function createDevConfig(config) {
const plugins = [];
if (config && config.serviceWorker) {
plugins.push(getSwDetails(), "new HtmlWebpackPlugin({filename:'index.html',template:'./templates/_index.html'})");
}
if (config && config.favPath) {
plugins.push(getWebappWebpackPlugin(config));
}
return { plugins };
}