Skip to content

Commit

Permalink
feat: add more nuxt module support
Browse files Browse the repository at this point in the history
  • Loading branch information
yjl9903 committed Feb 9, 2024
1 parent 8f4ea6e commit 9a7ab2a
Showing 1 changed file with 31 additions and 12 deletions.
43 changes: 31 additions & 12 deletions src/nuxt.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,36 @@
import { defineNuxtModule } from '@nuxt/kit';

import type { Options } from './core/types';

import { UnpluginInfo } from './core';

export default function (options: Options = {}, nuxt: any) {
// install webpack plugin
nuxt.hook('webpack:config', async (config: any) => {
config.plugins = config.plugins || [];
config.plugins.unshift(UnpluginInfo.webpack(options));
});
export default defineNuxtModule({

Check failure on line 7 in src/nuxt.ts

View workflow job for this annotation

GitHub Actions / build

The inferred type of 'default' cannot be named without a reference to '.pnpm/@nuxt+schema@3.10.0_rollup@4.9.6/node_modules/@nuxt/schema'. This is likely not portable. A type annotation is necessary.

Check failure on line 7 in src/nuxt.ts

View workflow job for this annotation

GitHub Actions / build

The inferred type of 'default' cannot be named without a reference to '.pnpm/@nuxt+schema@3.10.0_rollup@4.9.6/node_modules/@nuxt/schema'. This is likely not portable. A type annotation is necessary.
meta: {
// Usually the npm package name of your module
name: 'unplugin-info/nuxt',
// The key in `nuxt.config` that holds your module options
configKey: 'info',
// Compatibility constraints
compatibility: {
// Semver version of supported nuxt versions
nuxt: '^3.0.0'
}
},
// Default configuration options for your module, can also be a function returning those
defaults: {},
// Shorthand sugar to register Nuxt hooks
hooks: {},
setup(options: Options = {}, nuxt) {
// install webpack plugin
nuxt.hook('webpack:config', async (config: any) => {
config.plugins = config.plugins || [];
config.plugins.unshift(UnpluginInfo.webpack(options));
});

// install vite plugin
nuxt.hook('vite:extendConfig', async (config: any) => {
config.plugins = config.plugins || [];
config.plugins.push(UnpluginInfo.vite(options));
});
}
// install vite plugin
nuxt.hook('vite:extendConfig', async (config: any) => {
config.plugins = config.plugins || [];
config.plugins.push(UnpluginInfo.vite(options));
});
}
});

0 comments on commit 9a7ab2a

Please sign in to comment.