Skip to content

Commit 51dd132

Browse files
committed
chore: add example
1 parent 320086e commit 51dd132

File tree

15 files changed

+7941
-0
lines changed

15 files changed

+7941
-0
lines changed

example/README.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Extend example
2+
3+
This example is using `nuxt-extend` and [nuxt components](https://nuxtjs.org/docs/2.x/features/nuxt-components)
4+
to create a multi-variant mobile/desktop nuxt application.
5+
6+
- Using [yarn workspaces](https://classic.yarnpkg.com/en/docs/workspaces) for mono-repo managenment
7+
- Most of the logic is shared in base package
8+
- Using two sperate builds ensures that there are no additional dependencies leaked between mobile and desktop variants
9+
10+
## Configuration
11+
12+
- Add any common nuxt module and config to base ([base/nuxt.config](./packages/base/nuxt.config.js))
13+
- Avoid adding mobile/desktop specific modules, plugins and css
14+
- Instead use [desktop/nuxt.config](./packages/desktop/nuxt.config.js) and [mobile/nuxt.config](./packages/mobile/nuxt.config.js)
15+
16+
## Pages
17+
18+
Only top-level `pages/` directory is supported. It is best to always use a named component and implement per-variant.
19+
20+
## Store
21+
22+
Only top-level `store/` directory is supported. It is best to write shared logic inside vuex store modules.
23+
24+
## Layout
25+
26+
Using named components, it can be implemented with `components/AppLayout.vue` per-variant.
27+
28+
## Styles
29+
30+
It is recommended to use scoped styles. But in case that need to use global styles,
31+
they can be included in layout component or `nuxt.config` of each variant.

example/package.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"private": "true",
3+
"workspaces": [
4+
"packages/*"
5+
],
6+
"scripts": {
7+
"build": "",
8+
"dev:desktop": "nuxt dev packages/mobile",
9+
"dev:mobile": "nuxt dev packages/mobile"
10+
},
11+
"devDependencies": {
12+
"nuxt": "^2.14.7"
13+
}
14+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<template>
2+
<AppLayout />
3+
</template>

example/packages/base/nuxt.config.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { nuxtConfig } from 'nuxt-extend'
2+
3+
export default nuxtConfig({
4+
name: '@app/base',
5+
rootDir: __dirname
6+
})

example/packages/base/package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"name": "@app/base",
3+
"version": "0.0.0",
4+
"private": true
5+
}

example/packages/base/pages/index.vue

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<template>
2+
<AppLanding />
3+
</template>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<template>
2+
<div>
3+
<h1>
4+
Welcome to desktop version!
5+
</h1>
6+
</div>
7+
</template>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<template>
2+
<main>
3+
<Nuxt />
4+
<footer>
5+
<a href="/m/">Mobile Version</a>
6+
</footer>
7+
</main>
8+
</template>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { nuxtConfig } from 'nuxt-extend'
2+
3+
console.log(nuxtConfig({
4+
name: '@app/desktop',
5+
extends: '@app/base/nuxt.config'
6+
}))
7+
8+
export default nuxtConfig({
9+
name: '@app/desktop',
10+
extends: '@app/base/nuxt.config'
11+
})

example/packages/desktop/package.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"name": "@app/desktop",
3+
"version": "0.0.0",
4+
"private": true,
5+
"scripts": {
6+
"analyze": "nuxt build --analyze",
7+
"build": "nuxt build",
8+
"dev": "nuxt dev",
9+
"generate": "nuxt generate"
10+
}
11+
}

0 commit comments

Comments
 (0)