From 2341b0b5055bcc16ebf7ab8ccbcc3aaec5604fcf Mon Sep 17 00:00:00 2001 From: avil13 <13.avil@gmail.com> Date: Thu, 18 Mar 2021 13:21:50 +0300 Subject: [PATCH] fix: added different theme in nuxt - fixed #129 --- packages/vue-sweetalert2/README.md | 15 +++++++++++++++ packages/vue-sweetalert2/nuxt/no-css.js | 16 ++++++++++++++++ packages/vue-sweetalert2/nuxt/plugin.no-css.js | 8 ++++++++ 3 files changed, 39 insertions(+) create mode 100644 packages/vue-sweetalert2/nuxt/no-css.js create mode 100644 packages/vue-sweetalert2/nuxt/plugin.no-css.js diff --git a/packages/vue-sweetalert2/README.md b/packages/vue-sweetalert2/README.md index 9851067..b295520 100644 --- a/packages/vue-sweetalert2/README.md +++ b/packages/vue-sweetalert2/README.md @@ -177,4 +177,19 @@ Or pass in global options like this: } ``` +### Using a different theme in Nuxt + +Add `vue-sweetalert2/nuxt` to modules section of `nuxt.config.js` + +```js +{ + // Before doing so, install the "@sweetalert2/theme-dark" + css: [ '@sweetalert2/theme-dark' ], + modules: ['vue-sweetalert2/nuxt/no-css']; +} +``` + + + + ## The documentation for `sweetalert2`, you can find [here](https://sweetalert2.github.io/). diff --git a/packages/vue-sweetalert2/nuxt/no-css.js b/packages/vue-sweetalert2/nuxt/no-css.js new file mode 100644 index 0000000..46cd9b2 --- /dev/null +++ b/packages/vue-sweetalert2/nuxt/no-css.js @@ -0,0 +1,16 @@ +/* eslint-disable @typescript-eslint/no-var-requires */ +const { + resolve +} = require('path'); + +module.exports = function nuxtVueSweetalert2(moduleOptions) { + // Register plugin + this.addPlugin({ + src: resolve(__dirname, 'plugin.no-css.js'), + fileName: 'vue-sweetalert2.js', + options: moduleOptions, + ssr: false + }); +} + +module.exports.meta = require('../package.json'); diff --git a/packages/vue-sweetalert2/nuxt/plugin.no-css.js b/packages/vue-sweetalert2/nuxt/plugin.no-css.js new file mode 100644 index 0000000..091099a --- /dev/null +++ b/packages/vue-sweetalert2/nuxt/plugin.no-css.js @@ -0,0 +1,8 @@ +import Vue from 'vue'; +import VueSweetalert2 from 'vue-sweetalert2'; + +Vue.use(VueSweetalert2, <%= JSON.stringify(options, null, 2) %>); + +export default ({}, inject) => { + inject('swal', Vue.swal) +}