Skip to content

Commit

Permalink
support quasar v2
Browse files Browse the repository at this point in the history
  • Loading branch information
motia committed Jul 26, 2020
1 parent f72c05f commit 1991dd2
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 9 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Quasar Firebase Messaging App Extension
# Install
```bash
yarn add firebase
yarn add https://github.com/motia/quasar-app-extension-firebase-messaging
yarn add quasar-app-extension-firebase-messaging
quasar ext invoke firebase-messaging
```

Expand Down
23 changes: 18 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "quasar-app-extension-firebase-messaging",
"version": "0.0.1",
"version": "0.1.0",
"description": "Sets up FCM service worker for quasar applications",
"author": "Mouti'a Benachour <[email protected]>",
"license": "MIT",
Expand All @@ -10,13 +10,26 @@
},
"repository": {
"type": "git",
"url": "https://github.com/motia/quasar-app-extension-firebase-messaging"
"url": "git+https://github.com/motia/quasar-app-extension-firebase-messaging.git"
},
"bugs": "",
"homepage": "",
"bugs": {
"url": "https://github.com/motia/quasar-app-extension-firebase-messaging/issues"
},
"homepage": "https://github.com/motia/quasar-app-extension-firebase-messaging#readme",
"engines": {
"node": ">= 8.9.0",
"npm": ">= 5.6.0",
"yarn": ">= 1.6.0"
}
},
"keywords": [
"firebase-messaging",
"quasar",
"quasar-framework",
"pwa",
"FCM",
"firebase",
"push-notifications",
"vue",
"vue.js"
]
}
15 changes: 12 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,12 @@ function swTransformer(mode, path, content, userSWFilePath) {

const extendWebpackForWeb = function (conf, mode, appDir) {
const CopyPlugin = require('copy-webpack-plugin')
const copyPluginVersion = require('copy-webpack-plugin/package.json').version;

console.log(` App Extension (firebase): Configure webpack to copy service workers to root directory`)
const userSWFilePath = path.join(appDir, 'src-pwa', 'firebase-messaging-sw.js')

conf.plugins.push(new CopyPlugin([
const copyPluginPatternOptions = [
{
from: path.join(__dirname, 'templates', 'firebase-messaging-sw.js'),
to: '.',
Expand All @@ -49,11 +50,19 @@ const extendWebpackForWeb = function (conf, mode, appDir) {
userSWFilePath
)
}
]))
];

if (parseInt(copyPluginVersion) >= 6) {
copyPlugin = new CopyPlugin({ patterns: copyPluginPatternOptions });
} else {
copyPlugin = new CopyPlugin(copyPluginPatternOptions);

}
conf.plugins.push(copyPlugin)
}

module.exports = function (api) {
api.compatibleWith('@quasar/app', '^1.0.0')
api.compatibleWith('@quasar/app', '^1.0.0 || ^2.0.0')

const modeName = api.ctx.modeName
const appDir = api.appDir
Expand Down

0 comments on commit 1991dd2

Please sign in to comment.