Skip to content

Commit 3d8e84a

Browse files
committed
feat: create ionic.config.json if it doesn't already exist
1 parent edf1e93 commit 3d8e84a

File tree

4 files changed

+34
-34
lines changed

4 files changed

+34
-34
lines changed

README.md

Lines changed: 6 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77

88
> [Ionic](https://ionicframework.com/docs/) integration for [Nuxt](https://nuxtjs.org)
99
10-
[▶️  Online playground](https://stackblitz.com/github/danielroe/nuxt-ionic/tree/main/playground)
10+
- [ Changelog](https://github.com/danielroe/nuxt-ionic/blob/main/CHANGELOG.md)
11+
- [📖  Read the documentation](https://ionic.roe.dev)
12+
- [▶️  Online playground](https://stackblitz.com/github/danielroe/nuxt-ionic/tree/main/playground)
1113

1214
## Features
1315

@@ -25,38 +27,9 @@
2527

2628
- [ ] PWA Elements
2729

28-
## Quick setup
29-
30-
1. Add `nuxt-ionic` dependency to your project
31-
32-
```bash
33-
yarn add --dev nuxt-ionic
34-
# npm install -D nuxt-ionic
35-
# pnpm i -D nuxt-ionic
36-
```
37-
38-
1. Add `nuxt-ionic` to the `modules` section of `nuxt.config.ts`
39-
40-
```js
41-
import { defineNuxtConfig } from 'nuxt'
42-
43-
export default defineNuxtConfig({
44-
modules: ['nuxt-ionic'],
45-
ionic: {
46-
// default options - no configuration is required
47-
integrations: {
48-
meta: true,
49-
pwa: true,
50-
router: true,
51-
},
52-
css: {
53-
core: true,
54-
basic: true,
55-
utilities: false,
56-
},
57-
},
58-
})
59-
```
30+
## Usage
31+
32+
👉 Check out https://ionic.roe.dev.
6033

6134
## 💻 Development
6235

docs/content/2.getting-started.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ Finally, either remove your `app.vue` file or replace it with a custom one (star
3737

3838
You're good to go!
3939

40+
::alert{type=info}
41+
The first time you start a Nuxt project with `nuxt-ionic` enabled, a `ionic.config.json` file will be created if it doesn't already exist.
42+
::
43+
4044
## Options
4145

4246
While not required, you can configure the features that are enabled:

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,13 @@
5353
"postpublish": "pinst --enable"
5454
},
5555
"dependencies": {
56+
"@ionic/cli": "^6.20.0",
5657
"@ionic/vue": "^6.1.10",
5758
"@ionic/vue-router": "^6.1.10",
5859
"@kevinmarrec/nuxt-pwa": "^0.3.0",
5960
"@nuxt/kit": "^3.0.0-rc.4",
6061
"pathe": "^0.3.0",
62+
"pkg-types": "^0.3.3",
6163
"std-env": "^3.1.1",
6264
"ufo": "^0.8.4",
6365
"unimport": "^0.2.9"

src/module.ts

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
import { fileURLToPath } from 'url'
1+
import { existsSync, promises as fsp } from 'node:fs'
2+
import { fileURLToPath } from 'node:url'
23
import { join, resolve } from 'pathe'
4+
import { readPackageJSON } from 'pkg-types'
35
import { defineUnimportPreset } from 'unimport'
46
import {
57
defineNuxtModule,
@@ -46,6 +48,25 @@ export default defineNuxtModule<ModuleOptions>({
4648
nuxt.options.build.transpile.push(runtimeDir)
4749
nuxt.options.build.transpile.push(/@ionic/)
4850

51+
// Set up Ionic config
52+
const ionicConfigPath = join(nuxt.options.rootDir, 'ionic.config.json')
53+
if (!existsSync(ionicConfigPath)) {
54+
await fsp.writeFile(
55+
ionicConfigPath,
56+
JSON.stringify(
57+
{
58+
name: await readPackageJSON(nuxt.options.rootDir).then(
59+
({ name }) => name || 'nuxt-ionic-project'
60+
),
61+
integrations: {},
62+
type: 'vue',
63+
},
64+
null,
65+
2
66+
)
67+
)
68+
}
69+
4970
// Set up Ionic Core
5071
addPlugin(resolve(runtimeDir, 'ionic'))
5172

0 commit comments

Comments
 (0)