Skip to content
This repository has been archived by the owner on Apr 27, 2022. It is now read-only.

Commit

Permalink
feat(chore): created nuxt module
Browse files Browse the repository at this point in the history
  • Loading branch information
Intevel committed Apr 23, 2022
0 parents commit 59cda50
Show file tree
Hide file tree
Showing 13 changed files with 6,114 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .editorconfig
@@ -0,0 +1,12 @@
root = true

[*]
indent_size = 2
indent_style = space
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false
2 changes: 2 additions & 0 deletions .eslintignore
@@ -0,0 +1,2 @@
dist
node_modules
10 changes: 10 additions & 0 deletions .eslintrc
@@ -0,0 +1,10 @@
{
"extends": [
"@nuxtjs/eslint-config-typescript"
],
"rules": {
"@typescript-eslint/no-unused-vars": [
"off"
]
}
}
51 changes: 51 additions & 0 deletions .gitignore
@@ -0,0 +1,51 @@
# Dependencies
node_modules

# Logs
*.log*

# Temp directories
.temp
.tmp
.cache

# Yarn
**/.yarn/cache
**/.yarn/*state*

# Generated dirs
dist

# Nuxt
.nuxt
.output
.vercel_build_output
.build-*
.env
.netlify

# Env
.env

# Testing
reports
coverage
*.lcov
.nyc_output

# VSCode
.vscode

# Intellij idea
*.iml
.idea

# OSX
.DS_Store
.AppleDouble
.LSOverride
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk
6 changes: 6 additions & 0 deletions README.md
@@ -0,0 +1,6 @@
# Nuxt Module

## Development

- Run `npm run dev:prepare` to generate type stubs.
- Use `npm run dev` to start [playground](./playground) in development mode.
32 changes: 32 additions & 0 deletions package.json
@@ -0,0 +1,32 @@
{
"name": "nuxt-logsnag",
"version": "1.0.0",
"license": "MIT",
"type": "module",
"exports": {
".": {
"import": "./dist/module.mjs",
"require": "./dist/module.cjs"
}
},
"main": "./dist/module.cjs",
"types": "./dist/types.d.ts",
"files": [
"dist"
],
"scripts": {
"prepack": "nuxt-module-build",
"dev": "nuxi dev playground",
"dev:build": "nuxi build playground",
"dev:prepare": "nuxt-module-build --stub && nuxi prepare playground"
},
"dependencies": {
"@nuxt/kit": "^3.0.0-rc.1"
},
"devDependencies": {
"@nuxt/module-builder": "latest",
"@nuxtjs/eslint-config-typescript": "latest",
"eslint": "latest",
"nuxt": "^3.0.0-rc.1"
}
}
8 changes: 8 additions & 0 deletions playground/app.vue
@@ -0,0 +1,8 @@
<template>
<div>
Nuxt module playground!
</div>
</template>

<script setup>
</script>
11 changes: 11 additions & 0 deletions playground/nuxt.config.ts
@@ -0,0 +1,11 @@
import { defineNuxtConfig } from 'nuxt'
import MyModule from '..'

export default defineNuxtConfig({
modules: [
MyModule
],
myModule: {
addPlugin: true
}
})
4 changes: 4 additions & 0 deletions playground/package.json
@@ -0,0 +1,4 @@
{
"private": true,
"name": "my-module-playground"
}
24 changes: 24 additions & 0 deletions src/module.ts
@@ -0,0 +1,24 @@
import { resolve } from 'path'
import { fileURLToPath } from 'url'
import { defineNuxtModule, addPlugin } from '@nuxt/kit'

export interface ModuleOptions {
addPlugin: boolean
}

export default defineNuxtModule<ModuleOptions>({
meta: {
name: 'my-module',
configKey: 'myModule'
},
defaults: {
addPlugin: true
},
setup (options, nuxt) {
if (options.addPlugin) {
const runtimeDir = fileURLToPath(new URL('./runtime', import.meta.url))
nuxt.options.build.transpile.push(runtimeDir)
addPlugin(resolve(runtimeDir, 'plugin'))
}
}
})
5 changes: 5 additions & 0 deletions src/runtime/plugin.ts
@@ -0,0 +1,5 @@
import { defineNuxtPlugin } from '#app'

export default defineNuxtPlugin((nuxtApp) => {
console.log('Plugin by my-module!')
})
3 changes: 3 additions & 0 deletions tsconfig.json
@@ -0,0 +1,3 @@
{
"extends": "./playground/.nuxt/tsconfig.json"
}

0 comments on commit 59cda50

Please sign in to comment.