nuxt-loaders 1.1.2 → 1.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -21
- package/README.md +124 -124
- package/dist/bin/loaders.mjs +1 -1
- package/dist/module.json +1 -1
- package/dist/runtime/components/DefaultLoader.vue +3 -3
- package/dist/runtime/components/Loader.vue +6 -1
- package/dist/runtime/server/tsconfig.json +3 -3
- package/package.json +9 -1
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2025 Haileab Tesfaye
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Haileab Tesfaye
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,124 +1,124 @@
|
|
|
1
|
-
<!--
|
|
2
|
-
Get your module up and running quickly.
|
|
3
|
-
|
|
4
|
-
Find and replace all on all files (CMD+SHIFT+F):
|
|
5
|
-
- Name: Nuxt Loaders
|
|
6
|
-
- Package name: nuxt-loaders
|
|
7
|
-
- Description: Simple loading screen engine for Nuxt 4+
|
|
8
|
-
-->
|
|
9
|
-
|
|
10
|
-
# Nuxt Loaders
|
|
11
|
-
|
|
12
|
-
[![npm version][npm-version-src]][npm-version-href]
|
|
13
|
-
[![npm downloads][npm-downloads-src]][npm-downloads-href]
|
|
14
|
-
[![License][license-src]][license-href]
|
|
15
|
-
[![Nuxt][nuxt-src]][nuxt-href]
|
|
16
|
-
|
|
17
|
-
Simple loading screen engine for Nuxt 4+.
|
|
18
|
-
|
|
19
|
-
- [✨ Release Notes](/CHANGELOG.md)
|
|
20
|
-
<!-- - [🏀 Online playground](https://stackblitz.com/github/haileabt/nuxt-loaders?file=playground%2Fapp.vue) -->
|
|
21
|
-
<!-- - [📖 Documentation](https://example.com) -->
|
|
22
|
-
|
|
23
|
-
## Features
|
|
24
|
-
|
|
25
|
-
- 🔄 **Automatic Loader Registration**: Automatically registers loader components from your specified directory.
|
|
26
|
-
- 🛣️ **Route-based Configuration**: Assign specific loaders to different routes using `routeRules`.
|
|
27
|
-
- 🎨 **TailwindCSS Integration**: Includes TailwindCSS support out of the box.
|
|
28
|
-
- ⚡ **Zero Configuration**: Works with sensible defaults, but fully customizable.
|
|
29
|
-
|
|
30
|
-
## Quick Setup
|
|
31
|
-
|
|
32
|
-
1. Add `nuxt-loaders` dependency to your project
|
|
33
|
-
|
|
34
|
-
```bash
|
|
35
|
-
npx nuxi module add nuxt-loaders
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
2. Add `nuxt-loaders` to the `modules` section of `nuxt.config.ts`
|
|
39
|
-
|
|
40
|
-
```ts
|
|
41
|
-
export default defineNuxtConfig({
|
|
42
|
-
modules: ["nuxt-loaders"],
|
|
43
|
-
});
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
That's it! You can now use Nuxt Loaders in your Nuxt app ✨
|
|
47
|
-
|
|
48
|
-
## Configuration
|
|
49
|
-
|
|
50
|
-
You can configure the module in your `nuxt.config.ts
|
|
51
|
-
|
|
52
|
-
```ts
|
|
53
|
-
export default defineNuxtConfig({
|
|
54
|
-
modules: ["nuxt-loaders"],
|
|
55
|
-
loaders: {
|
|
56
|
-
// Directory containing your loader components
|
|
57
|
-
// Default: 'app/components/loaders'
|
|
58
|
-
loadersDir: "app/components/loaders",
|
|
59
|
-
|
|
60
|
-
// Automatically setup the module
|
|
61
|
-
// Default: true
|
|
62
|
-
autoSetup: true,
|
|
63
|
-
|
|
64
|
-
// Define rules for which loader to use on which route
|
|
65
|
-
routeRules: {
|
|
66
|
-
"/": "MyLoader",
|
|
67
|
-
"/admin/*": "AdminLoader",
|
|
68
|
-
},
|
|
69
|
-
},
|
|
70
|
-
});
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
### Options
|
|
74
|
-
|
|
75
|
-
| Option | Type | Default | Description |
|
|
76
|
-
| ------------ | ------------------------ | -------------------------- | --------------------------------------------------- |
|
|
77
|
-
| `loadersDir` | `string` | `'app/components/loaders'` | Directory where your loader components are located. |
|
|
78
|
-
| `autoSetup` | `boolean` | `true` | Whether to automatically setup the module. |
|
|
79
|
-
| `routeRules` | `Record<string, string>` | `{}` | Map of route patterns to loader component names. |
|
|
80
|
-
|
|
81
|
-
## Usage
|
|
82
|
-
|
|
83
|
-
1. **Add the Loader Component**:
|
|
84
|
-
Add the `<Loader />` component to your `app.vue` (or layout) and control its visibility using `useLoader`.
|
|
85
|
-
|
|
86
|
-
```vue
|
|
87
|
-
<script setup lang="ts">
|
|
88
|
-
const { isLoading } = useLoader();
|
|
89
|
-
</script>
|
|
90
|
-
|
|
91
|
-
<template>
|
|
92
|
-
<Loader v-if="isLoading" />
|
|
93
|
-
<NuxtPage />
|
|
94
|
-
</template>
|
|
95
|
-
```
|
|
96
|
-
|
|
97
|
-
2. **Create your loader components**:
|
|
98
|
-
Place them in `app/components/loaders` (or your configured `loadersDir`).
|
|
99
|
-
|
|
100
|
-
3. **Configure Route Rules**:
|
|
101
|
-
Use `routeRules` in your `nuxt.config.ts` to specify which loader should be active for specific routes.
|
|
102
|
-
|
|
103
|
-
Example loader component (`app/components/loaders/MyLoader.vue`):
|
|
104
|
-
|
|
105
|
-
```vue
|
|
106
|
-
<template>
|
|
107
|
-
<div class="loader">Loading...</div>
|
|
108
|
-
</template>
|
|
109
|
-
```
|
|
110
|
-
|
|
111
|
-
## Contribution
|
|
112
|
-
|
|
113
|
-
Please read [CONTRIBUTING.md](CONTRIBUTING.md) for details on our code of conduct, and the process for submitting pull requests to us.
|
|
114
|
-
|
|
115
|
-
<!-- Badges -->
|
|
116
|
-
|
|
117
|
-
[npm-version-src]: https://img.shields.io/npm/v/nuxt-loaders/latest.svg?style=flat&colorA=020420&colorB=00DC82
|
|
118
|
-
[npm-version-href]: https://npmjs.com/package/nuxt-loaders
|
|
119
|
-
[npm-downloads-src]: https://img.shields.io/npm/dm/nuxt-loaders.svg?style=flat&colorA=020420&colorB=00DC82
|
|
120
|
-
[npm-downloads-href]: https://npm.chart.dev/nuxt-loaders
|
|
121
|
-
[license-src]: https://img.shields.io/npm/l/nuxt-loaders.svg?style=flat&colorA=020420&colorB=00DC82
|
|
122
|
-
[license-href]: https://npmjs.com/package/nuxt-loaders
|
|
123
|
-
[nuxt-src]: https://img.shields.io/badge/Nuxt-020420?logo=nuxt.js
|
|
124
|
-
[nuxt-href]: https://nuxt.com
|
|
1
|
+
<!--
|
|
2
|
+
Get your module up and running quickly.
|
|
3
|
+
|
|
4
|
+
Find and replace all on all files (CMD+SHIFT+F):
|
|
5
|
+
- Name: Nuxt Loaders
|
|
6
|
+
- Package name: nuxt-loaders
|
|
7
|
+
- Description: Simple loading screen engine for Nuxt 4+
|
|
8
|
+
-->
|
|
9
|
+
|
|
10
|
+
# Nuxt Loaders
|
|
11
|
+
|
|
12
|
+
[![npm version][npm-version-src]][npm-version-href]
|
|
13
|
+
[![npm downloads][npm-downloads-src]][npm-downloads-href]
|
|
14
|
+
[![License][license-src]][license-href]
|
|
15
|
+
[![Nuxt][nuxt-src]][nuxt-href]
|
|
16
|
+
|
|
17
|
+
Simple loading screen engine for Nuxt 4+.
|
|
18
|
+
|
|
19
|
+
- [✨ Release Notes](/CHANGELOG.md)
|
|
20
|
+
<!-- - [🏀 Online playground](https://stackblitz.com/github/haileabt/nuxt-loaders?file=playground%2Fapp.vue) -->
|
|
21
|
+
<!-- - [📖 Documentation](https://example.com) -->
|
|
22
|
+
|
|
23
|
+
## Features
|
|
24
|
+
|
|
25
|
+
- 🔄 **Automatic Loader Registration**: Automatically registers loader components from your specified directory as global components.
|
|
26
|
+
- 🛣️ **Route-based Configuration**: Assign specific loaders to different routes using `routeRules`.
|
|
27
|
+
- 🎨 **TailwindCSS Integration**: Includes TailwindCSS support out of the box.
|
|
28
|
+
- ⚡ **Zero Configuration**: Works with sensible defaults, but is fully customizable.
|
|
29
|
+
|
|
30
|
+
## Quick Setup
|
|
31
|
+
|
|
32
|
+
1. Add `nuxt-loaders` dependency to your project:
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
npx nuxi module add nuxt-loaders
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
2. Add `nuxt-loaders` to the `modules` section of `nuxt.config.ts` (if not already added by nuxi):
|
|
39
|
+
|
|
40
|
+
```ts
|
|
41
|
+
export default defineNuxtConfig({
|
|
42
|
+
modules: ["nuxt-loaders"],
|
|
43
|
+
});
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
That's it! You can now use Nuxt Loaders in your Nuxt app ✨
|
|
47
|
+
|
|
48
|
+
## Configuration
|
|
49
|
+
|
|
50
|
+
You can configure the module in your `nuxt.config.ts`. The components in `loadersDir` will be automatically imported and can be referenced by name in `routeRules`.
|
|
51
|
+
|
|
52
|
+
```ts
|
|
53
|
+
export default defineNuxtConfig({
|
|
54
|
+
modules: ["nuxt-loaders"],
|
|
55
|
+
loaders: {
|
|
56
|
+
// Directory containing your loader components
|
|
57
|
+
// Default: 'app/components/loaders'
|
|
58
|
+
loadersDir: "app/components/loaders",
|
|
59
|
+
|
|
60
|
+
// Automatically setup the module
|
|
61
|
+
// Default: true
|
|
62
|
+
autoSetup: true,
|
|
63
|
+
|
|
64
|
+
// Define rules for which loader to use on which route
|
|
65
|
+
routeRules: {
|
|
66
|
+
"/": "MyLoader",
|
|
67
|
+
"/admin/*": "AdminLoader",
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
});
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### Options
|
|
74
|
+
|
|
75
|
+
| Option | Type | Default | Description |
|
|
76
|
+
| ------------ | ------------------------ | -------------------------- | --------------------------------------------------- |
|
|
77
|
+
| `loadersDir` | `string` | `'app/components/loaders'` | Directory where your loader components are located. |
|
|
78
|
+
| `autoSetup` | `boolean` | `true` | Whether to automatically setup the module. |
|
|
79
|
+
| `routeRules` | `Record<string, string>` | `{}` | Map of route patterns to loader component names. |
|
|
80
|
+
|
|
81
|
+
## Usage
|
|
82
|
+
|
|
83
|
+
1. **Add the Loader Component**:
|
|
84
|
+
Add the `<Loader />` component to your `app.vue` (or layout) and control its visibility using `useLoader`.
|
|
85
|
+
|
|
86
|
+
```vue
|
|
87
|
+
<script setup lang="ts">
|
|
88
|
+
const { isLoading } = useLoader();
|
|
89
|
+
</script>
|
|
90
|
+
|
|
91
|
+
<template>
|
|
92
|
+
<Loader v-if="isLoading" />
|
|
93
|
+
<NuxtPage />
|
|
94
|
+
</template>
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
2. **Create your loader components**:
|
|
98
|
+
Place them in `app/components/loaders` (or your configured `loadersDir`).
|
|
99
|
+
|
|
100
|
+
3. **Configure Route Rules**:
|
|
101
|
+
Use `routeRules` in your `nuxt.config.ts` to specify which loader should be active for specific routes.
|
|
102
|
+
|
|
103
|
+
Example loader component (`app/components/loaders/MyLoader.vue`):
|
|
104
|
+
|
|
105
|
+
```vue
|
|
106
|
+
<template>
|
|
107
|
+
<div class="loader">Loading...</div>
|
|
108
|
+
</template>
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
## Contribution
|
|
112
|
+
|
|
113
|
+
Please read [CONTRIBUTING.md](CONTRIBUTING.md) for details on our code of conduct, and the process for submitting pull requests to us.
|
|
114
|
+
|
|
115
|
+
<!-- Badges -->
|
|
116
|
+
|
|
117
|
+
[npm-version-src]: https://img.shields.io/npm/v/nuxt-loaders/latest.svg?style=flat&colorA=020420&colorB=00DC82
|
|
118
|
+
[npm-version-href]: https://npmjs.com/package/nuxt-loaders
|
|
119
|
+
[npm-downloads-src]: https://img.shields.io/npm/dm/nuxt-loaders.svg?style=flat&colorA=020420&colorB=00DC82
|
|
120
|
+
[npm-downloads-href]: https://npm.chart.dev/nuxt-loaders
|
|
121
|
+
[license-src]: https://img.shields.io/npm/l/nuxt-loaders.svg?style=flat&colorA=020420&colorB=00DC82
|
|
122
|
+
[license-href]: https://npmjs.com/package/nuxt-loaders
|
|
123
|
+
[nuxt-src]: https://img.shields.io/badge/Nuxt-020420?logo=nuxt.js
|
|
124
|
+
[nuxt-href]: https://nuxt.com
|
package/dist/bin/loaders.mjs
CHANGED
|
@@ -102,7 +102,7 @@ const handleAddLoader = async (slug, loadersConfig, index) => {
|
|
|
102
102
|
}
|
|
103
103
|
const loadersPath = join(process.cwd(), loadersConfig.loadersDir);
|
|
104
104
|
if (!existsSync(loadersPath)) {
|
|
105
|
-
mkdirSync(loadersPath);
|
|
105
|
+
mkdirSync(loadersPath, { recursive: true });
|
|
106
106
|
logInfoCli(`Created loaders directory at ${loadersPath}`);
|
|
107
107
|
}
|
|
108
108
|
const loader = loadersConfig.installedLoaders[slug];
|
package/dist/module.json
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<div
|
|
2
|
+
<div
|
|
3
|
+
:class="[
|
|
4
|
+
className,
|
|
5
|
+
'w-screen h-svh fixed top-0 left-0 z-50 grid place-items-center bg-black'
|
|
6
|
+
]"
|
|
7
|
+
>
|
|
3
8
|
<component :is="loaderName" />
|
|
4
9
|
</div>
|
|
5
10
|
</template>
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "../../../.nuxt/tsconfig.server.json",
|
|
3
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"extends": "../../../.nuxt/tsconfig.server.json",
|
|
3
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nuxt-loaders",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.4",
|
|
4
4
|
"description": "Simple loading screen engine for Nuxt 4+",
|
|
5
5
|
"repository": "haileabt/nuxt-loaders",
|
|
6
6
|
"license": "MIT",
|
|
@@ -23,6 +23,14 @@
|
|
|
23
23
|
"files": [
|
|
24
24
|
"dist"
|
|
25
25
|
],
|
|
26
|
+
"keywords": [
|
|
27
|
+
"nuxt",
|
|
28
|
+
"nuxt 4",
|
|
29
|
+
"nuxt-loaders",
|
|
30
|
+
"loaders",
|
|
31
|
+
"loading screens",
|
|
32
|
+
"vue"
|
|
33
|
+
],
|
|
26
34
|
"bin": {
|
|
27
35
|
"loaders": "./dist/bin/loaders.mjs"
|
|
28
36
|
},
|