generated from justintaddei/npm-ts-template
-
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add support for nuxt3 via postinstall script
- Loading branch information
justintaddei
committed
Nov 7, 2023
1 parent
deedebe
commit 352cf03
Showing
6 changed files
with
48 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
const fs = require('fs') | ||
const path = require('path') | ||
|
||
const pkg = require(path.join(process.env.INIT_CWD, 'package.json')) | ||
|
||
const nuxtVersion = pkg.dependencies.nuxt ?? pkg.devDependencies.nuxt | ||
|
||
if (!nuxtVersion || /2\.\d+\.\d+/.test(nuxtVersion)) { | ||
process.exit(0) | ||
} | ||
|
||
if (!fs.existsSync(path.join(process.env.INIT_CWD, 'plugins'))) { | ||
fs.mkdirSync(path.join(process.env.INIT_CWD, 'plugins')) | ||
} | ||
|
||
try { | ||
fs.copyFileSync( | ||
path.join(__dirname, 'v-wave.client.ts'), | ||
path.join(process.env.INIT_CWD, 'plugins', 'v-wave.client.ts'), | ||
fs.constants.COPYFILE_EXCL | ||
) | ||
fs.copyFileSync( | ||
path.join(__dirname, 'v-wave.server.ts'), | ||
path.join(process.env.INIT_CWD, 'plugins', 'v-wave.server.ts'), | ||
fs.constants.COPYFILE_EXCL | ||
) | ||
} catch (e) { | ||
process.exit(0) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import vWave, { type IVWavePluginOptions } from 'v-wave' | ||
|
||
export const options: Partial<IVWavePluginOptions> = { | ||
// Place any global v-wave options here | ||
} | ||
|
||
export default defineNuxtPlugin((nuxtApp) => { | ||
nuxtApp.vueApp.use(vWave, options) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { options } from './v-wave.client'; | ||
|
||
export default defineNuxtPlugin(({ vueApp }) => { | ||
vueApp.directive(options.directive ?? 'wave', {}); | ||
vueApp.directive(`${options.directive ?? 'wave'}-trigger`, {}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters