Skip to content

Commit

Permalink
fix: added different theme in nuxt - fixed #129
Browse files Browse the repository at this point in the history
  • Loading branch information
avil13 committed Mar 18, 2021
1 parent 78d5f96 commit 2341b0b
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 0 deletions.
15 changes: 15 additions & 0 deletions packages/vue-sweetalert2/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/).
16 changes: 16 additions & 0 deletions packages/vue-sweetalert2/nuxt/no-css.js
Original file line number Diff line number Diff line change
@@ -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');
8 changes: 8 additions & 0 deletions packages/vue-sweetalert2/nuxt/plugin.no-css.js
Original file line number Diff line number Diff line change
@@ -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)
}

0 comments on commit 2341b0b

Please sign in to comment.