From fb4621f8eff275118b80fe176374d7e94f3f4a6b Mon Sep 17 00:00:00 2001 From: Hendrik Bursian Date: Sun, 16 Aug 2020 16:56:40 +0200 Subject: [PATCH] Replace NodeJS methods with native javascript Fixes rishabh3112/gridsome-plugin-pwa#50 When fixing the path generation for "msapplication-TileImage" #48 NodeJS methods were used. This commit fixes the usage of NodeJS which is not available in the browser. --- gridsome.client.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/gridsome.client.js b/gridsome.client.js index f780960..7de08c0 100644 --- a/gridsome.client.js +++ b/gridsome.client.js @@ -1,4 +1,3 @@ -const { parse } = require('path'); const { register } = require('register-service-worker'); const clientConfig = function (Vue, options, context) { @@ -30,9 +29,17 @@ const clientConfig = function (Vue, options, context) { }) } - const iconsDir = 'assets/static/'; - const iconPathParsed = parse(options.icon); - const msTileImage = `/${iconsDir}${iconPathParsed.name}-144x144${iconPathParsed.ext}`; + const iconsDir = '/assets/static/'; + const iconName = options.icon.split('/').slice(-1)[0]; + const iconNameDotIdx = iconName.lastIndexOf('.'); + + var msTileImage = iconsDir; + + if(iconNameDotIdx > -1) { + msTileImage += `${iconName.substring(0, iconNameDotIdx)}-144x144${iconName.substring(iconNameDotIdx)}` + } else { + msTileImage += `${iconName}-144x144` + } head.link.push({ rel: 'manifest',