Skip to content

Commit

Permalink
Merge pull request #78 from IBEC-BOX/fix/config
Browse files Browse the repository at this point in the history
Fix/config
  • Loading branch information
Aidosgd authored Feb 22, 2024
2 parents c192c2e + e7c0368 commit d7fe1ee
Show file tree
Hide file tree
Showing 2 changed files with 108 additions and 66 deletions.
3 changes: 2 additions & 1 deletion playground/nuxt.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
export default defineNuxtConfig({
modules: ['../src/module', '@pinia/nuxt'],
nuxt3UIKit: {
theme: 'green'
theme: 'dark',
components: ['pagesTestVuetify', 'partsFooterDefault', 'partsCard', 'partsForms', 'partsErgVacancies', 'partsHeaderDefault', 'partsHeaderErg']
},
devtools: { enabled: true },
build: {
Expand Down
171 changes: 106 additions & 65 deletions src/module.ts
Original file line number Diff line number Diff line change
@@ -1,87 +1,128 @@
import {addComponent, addPlugin, createResolver, defineNuxtModule} from '@nuxt/kit'
import {
addComponent,
addPlugin,
createResolver,
defineNuxtModule,
} from "@nuxt/kit";

// Module options TypeScript interface definition
export interface ModuleOptions {}
export interface ModuleOptions {
theme: string;
components: string[];
}

export default defineNuxtModule<ModuleOptions>({
meta: {
name: 'nuxt3-ui-kit',
configKey: 'nuxt3UIKit'
name: "nuxt3-ui-kit",
configKey: "nuxt3UIKit",
},
// Default configuration options of the Nuxt module
defaults: {
theme: 'light'
theme: "light",
components: []
},
setup (options, nuxt) {
const resolver = createResolver(import.meta.url)
const runtimeDir = resolver.resolve('./runtime')
setup(options, nuxt) {
const resolver = createResolver(import.meta.url);
const runtimeDir = resolver.resolve("./runtime");

const isDevelopment = runtimeDir.endsWith('src/runtime') || runtimeDir.endsWith('src\\runtime')
const isDevelopment =
runtimeDir.endsWith("src/runtime") || runtimeDir.endsWith("src\\runtime");

const extension = isDevelopment ? 'scss' : 'css'
const extension = isDevelopment ? "scss" : "css";

// Do not add the extension since the `.ts` will be transpiled to `.mjs` after `npm run prepack`
addPlugin(resolver.resolve('./runtime/plugin'))
addPlugin(resolver.resolve("./runtime/plugin"));

nuxt.options.css.push(resolver.resolve(`./runtime/plugins/vuetify/styles.${extension}`))
nuxt.options.css.push(
resolver.resolve(`./runtime/plugins/vuetify/styles.${extension}`)
);

// Components
addComponent({
name: 'pagesTestVuetify', // name of the component to be used in vue templates
filePath: resolver.resolve('runtime/components/Pages/TestVuetify.vue')
})

addComponent({
name: 'partsFooterDefault', // name of the component to be used in vue templates
filePath: resolver.resolve('runtime/components/Parts/Footer/Default.vue')
})

addComponent({
name: 'partsCard', // name of the component to be used in vue templates
filePath: resolver.resolve('runtime/components/Parts/Card.vue')
})

addComponent({
name: 'partsForms', // name of the component to be used in vue templates
filePath: resolver.resolve('runtime/components/Parts/Forms.vue')
})

addComponent({
name: 'partsErgVacancies', // name of the component to be used in vue templates
filePath: resolver.resolve('runtime/components/Parts/ErgVacancies.vue')
})

// Header
addComponent( {
name: 'partsHeaderDefault',
filePath: resolver.resolve('runtime/components/Parts/Header/Default.vue')
})
if (options.components.includes("pagesTestVuetify")) {
addComponent({
name: "pagesTestVuetify", // name of the component to be used in vue templates
filePath: resolver.resolve("runtime/components/Pages/TestVuetify.vue"),
});
}

if (options.components.includes("partsFooterDefault")) {
addComponent({
name: "partsFooterDefault", // name of the component to be used in vue templates
filePath: resolver.resolve(
"runtime/components/Parts/Footer/Default.vue"
),
});
}

if (options.components.includes("partsCard")) {
addComponent({
name: "partsCard", // name of the component to be used in vue templates
filePath: resolver.resolve("runtime/components/Parts/Card.vue"),
});
}

if (options.components.includes("partsForms")) {
addComponent({
name: "partsForms", // name of the component to be used in vue templates
filePath: resolver.resolve("runtime/components/Parts/Forms.vue"),
});
}

if (options.components.includes("partsErgVacancies")) {
addComponent({
name: "partsErgVacancies", // name of the component to be used in vue templates
filePath: resolver.resolve("runtime/components/Parts/ErgVacancies.vue"),
});
}

addComponent( {
name: 'partsHeaderErg',
filePath: resolver.resolve('runtime/components/Parts/Header/Erg.vue')
})
// Header
if (options.components.includes("partsHeaderDefault")) {
addComponent({
name: "partsHeaderDefault",
filePath: resolver.resolve(
"runtime/components/Parts/Header/Default.vue"
),
});
}

if (options.components.includes("partsHeaderErg")) {
addComponent({
name: "partsHeaderErg",
filePath: resolver.resolve("runtime/components/Parts/Header/Erg.vue"),
});
}

// Modal
addComponent( {
name: 'partsModal',
filePath: resolver.resolve('runtime/components/Parts/Modal.vue')
})
if (options.components.includes("partsModal")) {
addComponent({
name: "partsModal",
filePath: resolver.resolve("runtime/components/Parts/Modal.vue"),
});
}

//Slider
addComponent({
name: 'partsSlider',
filePath: resolver.resolve('runtime/components/Parts/Slider.vue')
})

addComponent({
name: 'partsNews',
filePath: resolver.resolve('runtime/components/Parts/News.vue')
})

addComponent({
name: 'partsFilesDownloadFiles',
filePath: resolver.resolve('runtime/components/Parts/Files/DownloadFiles.vue')
})
}
})
if (options.components.includes("partsSlider")) {
addComponent({
name: "partsSlider",
filePath: resolver.resolve("runtime/components/Parts/Slider.vue"),
});
}

if (options.components.includes("partsNews")) {
addComponent({
name: "partsNews",
filePath: resolver.resolve("runtime/components/Parts/News.vue"),
});
}

if (options.components.includes("partsFilesDownloadFiles")) {
addComponent({
name: "partsFilesDownloadFiles",
filePath: resolver.resolve(
"runtime/components/Parts/Files/DownloadFiles.vue"
),
});
}
},
});

0 comments on commit d7fe1ee

Please sign in to comment.