Skip to content
This repository was archived by the owner on Mar 4, 2025. It is now read-only.

Commit 1bbe461

Browse files
committed
refactor: make package and nuxt.config templates more readable
1 parent 650fe6c commit 1bbe461

File tree

4 files changed

+161
-99
lines changed

4 files changed

+161
-99
lines changed

template/_package.json

Lines changed: 88 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -4,33 +4,52 @@
44
"description": "<%= description %>",
55
"author": "<%= author %>",
66
"private": true,
7-
"scripts": {<% if (server === 'adonis') { %>
7+
"scripts": {
8+
<%_ if (eslint === 'yes') { _%>
9+
"lint": "eslint --ext .js,.vue --ignore-path .gitignore .",
10+
"precommit": "<%= pm %> run lint",
11+
<%_ } _%>
12+
<%_ if (test !== 'none') { _%>
13+
"test": "<%= test %>",
14+
<%_ } _%>
15+
<%_ if (server === 'none') { _%>
16+
"dev": "nuxt",
17+
"build": "nuxt build",
18+
"start": "nuxt start",
19+
"generate": "nuxt generate"
20+
<%_ } else if (server === 'adonis') { _%>
821
"serve:dev": "<%= pm %> run dev",
922
"dev": "nodemon --watch app --watch bootstrap --watch config --watch .env -x node server.js",
1023
"build": "cross-env NODE_ENV=production node ./ace nuxtbuild",
11-
"start": "cross-env NODE_ENV=production node server.js"<% } else { %>
12-
"dev": "<% if (server === 'none') { %>nuxt<% } else { %>cross-env NODE_ENV=development nodemon server/index.js --watch server<% } %>",
24+
"start": "cross-env NODE_ENV=production node server.js"
25+
<%_ } else { _%>
26+
"dev": "cross-env NODE_ENV=development nodemon server/index.js --watch server",
1327
"build": "nuxt build",
14-
"start": "<% if (server === 'none') { %>nuxt start<% } else { %>cross-env NODE_ENV=production node server/index.js<% } %>",
15-
"generate": "nuxt generate"<% } %><% if (eslint === 'yes') { %>,
16-
"lint": "eslint --ext .js,.vue --ignore-path .gitignore .",
17-
"precommit": "<%= pm %> run lint"<% } %><% if (test !== 'none') { %>,
18-
"test": "<%= test %>"<% } %>
28+
"start": "cross-env NODE_ENV=production node server/index.js",
29+
"generate": "nuxt generate"
30+
<%_ } _%>
1931
},
2032
"dependencies": {
21-
"cross-env": "^5.2.0"<% if (edge) { %>,
22-
"nuxt-edge": "latest"<% } else { %>,
23-
"nuxt": "^2.0.0"<% } %><% if (server === 'express') { %>,
24-
"express": "^4.16.4"<% } else if (server === 'koa') { %>,
25-
"koa": "^2.6.2"<% } else if (server === 'hapi') { %>,
33+
<%_ if (server !== 'none') { _%>
34+
"cross-env": "^5.2.0",
35+
<%_ } _%>
36+
<%_ if (server === 'express') { _%>
37+
"express": "^4.16.4",
38+
<%_ } else if (server === 'koa') { _%>
39+
"koa": "^2.6.2",
40+
<%_ } else if (server === 'hapi') { _%>
2641
"@hapi/hapi": "^18.3.1",
27-
"@nuxtjs/hapi": "^2.2.1"<% } else if (server === 'micro') { %>,
42+
"@nuxtjs/hapi": "^2.2.1",
43+
<%_ } else if (server === 'micro') { _%>
2844
"micro": "^9.3.3",
29-
"micro-route": "^2.5.0"<% } else if (server === 'fastify') { %>,
30-
"fastify": "^1.13.3"<% } else if (server === 'feathers') { %>,
45+
"micro-route": "^2.5.0",
46+
<%_ } else if (server === 'fastify') { _%>
47+
"fastify": "^1.13.3",
48+
<%_ } else if (server === 'feathers') { _%>
3149
"@feathersjs/feathers": "^3.3.1",
3250
"@feathersjs/express": "^1.3.1",
33-
"@feathersjs/configuration": "^2.0.6"<% } else if (server === 'adonis') { %>,
51+
"@feathersjs/configuration": "^2.0.6",
52+
<%_ } else if (server === 'adonis') { _%>
3453
"@adonisjs/ace": "^4.0.7",
3554
"@adonisjs/auth": "^2.0.10",
3655
"@adonisjs/bodyparser": "^1.0.8",
@@ -40,21 +59,47 @@
4059
"@adonisjs/ignitor": "^1.0.14",
4160
"@adonisjs/lucid": "^4.0.22",
4261
"@adonisjs/session": "^1.0.19",
43-
"@adonisjs/shield": "^1.0.4"<% } %><% if (ui === 'bootstrap') { %>,
62+
"@adonisjs/shield": "^1.0.4",
63+
<%_ } _%>
64+
<%_ if (ui === 'bootstrap') { _%>
4465
"bootstrap-vue": "^2.0.0-rc.11",
45-
"bootstrap": "^4.1.3"<% } else if (ui === 'vuetify') { %>,
46-
"@nuxtjs/vuetify": "0.5.5"<% } else if (ui === 'bulma') { %>,
47-
"@nuxtjs/bulma": "^1.2.1"<% } else if (ui === 'element-ui') { %>,
48-
"element-ui": "^2.4.11"<% } else if (ui === 'ant-design-vue') { %>,
49-
"ant-design-vue": "^1.1.10"<% } else if (ui === 'buefy') { %>,
50-
"nuxt-buefy": "^0.3.2"<% } else if (ui === 'iview') { %>,
51-
"iview": "3.1.5"<% } %><% if (axios === 'yes') { %>,
52-
"@nuxtjs/axios": "^5.3.6"<% } %><% if (pwa === 'yes') { %>,
53-
"@nuxtjs/pwa": "^2.6.0"<% } %><% if (ui === 'tachyons') { %>,
54-
"tachyons": "^4.11.1"<% } %>
66+
"bootstrap": "^4.1.3",
67+
<%_ } else if (ui === 'vuetify') { _%>
68+
"@nuxtjs/vuetify": "0.5.5",
69+
<%_ } else if (ui === 'bulma') { _%>
70+
"@nuxtjs/bulma": "^1.2.1",
71+
<%_ } else if (ui === 'element-ui') { _%>
72+
"element-ui": "^2.4.11",
73+
<%_ } else if (ui === 'ant-design-vue') { _%>
74+
"ant-design-vue": "^1.1.10"
75+
<%_ } else if (ui === 'buefy') { _%>
76+
"nuxt-buefy": "^0.3.2",
77+
<%_ } else if (ui === 'iview') { _%>
78+
"iview": "3.1.5",
79+
<%_ } _%>
80+
<%_ if (axios === 'yes') { _%>
81+
"@nuxtjs/axios": "^5.3.6",
82+
<%_ } _%>
83+
<%_ if (pwa === 'yes') { _%>
84+
"@nuxtjs/pwa": "^2.6.0",
85+
<%_ } _%>
86+
<%_ if (ui === 'tachyons') { _%>
87+
"tachyons": "^4.11.1",
88+
<%_ } _%>
89+
<%_ if (edge) { _%>
90+
"nuxt-edge": "latest"
91+
<%_ } else { _%>
92+
"nuxt": "^2.0.0"
93+
<%_ } _%>
5594
},
5695
"devDependencies": {
57-
"nodemon": "^1.18.9"<% if (eslint === 'yes') { %>,
96+
<%_ if (ui === 'tailwind') { _%>
97+
"tailwindcss": "^1.0.0",
98+
<%_ } else if (ui === 'vuetify') { _%>
99+
"stylus": "^0.54.5",
100+
"stylus-loader": "^3.0.2",
101+
<%_ } _%>
102+
<%_ if (eslint === 'yes') { _%>
58103
"@nuxtjs/eslint-config": "^0.0.1",
59104
"@nuxtjs/eslint-module": "^0.0.1",
60105
"babel-eslint": "^10.0.1",
@@ -66,22 +111,28 @@
66111
"eslint-plugin-nuxt": ">=0.4.2",
67112
"eslint-plugin-promise": ">=4.0.1",
68113
"eslint-plugin-standard": ">=4.0.0",
69-
"eslint-plugin-vue": "^5.2.2"<% } %><% if (prettier === 'yes') { %>,
114+
"eslint-plugin-vue": "^5.2.2",
115+
<%_ } _%>
116+
<%_ if (prettier === 'yes') { _%>
70117
"eslint-config-prettier": "^4.1.0",
71118
"eslint-plugin-prettier": "^3.0.1",
72-
"prettier": "^1.16.4"<% } %><% if (ui === 'tailwind') { %>,
73-
"tailwindcss": "^1.0.0"<% } else if (ui === 'vuetify') { %>,
74-
"stylus": "^0.54.5",
75-
"stylus-loader": "^3.0.2"<% } %><% if (test !== 'none') { %>,
76-
"@vue/test-utils": "^1.0.0-beta.27"<% } %><% if (test === 'jest') { %>,
119+
"prettier": "^1.16.4",
120+
<%_ } _%>
121+
<%_ if (test !== 'none') { _%>
122+
"@vue/test-utils": "^1.0.0-beta.27",
123+
<%_ } _%>
124+
<%_ if (test === 'jest') { _%>
77125
"babel-core": "7.0.0-bridge.0",
78126
"babel-jest": "^24.1.0",
79127
"jest": "^24.1.0",
80-
"vue-jest": "^3.0.3"<% } %><% if (test === 'ava') { %>,
128+
"vue-jest": "^3.0.3",
129+
<%_ } else if (test === 'ava') { _%>
81130
"ava": "^1.0.1",
82131
"browser-env": "^3.2.5",
83132
"require-extension-hooks": "^0.3.3",
84133
"require-extension-hooks-babel": "^0.1.1",
85-
"require-extension-hooks-vue": "^2.0.0"<% } %>
134+
"require-extension-hooks-vue": "^2.0.0",
135+
<%_ } _%>
136+
"nodemon": "^1.18.9"
86137
}
87138
}

template/nuxt/nuxt.config.js

Lines changed: 73 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,33 @@
1-
<% if (esm) { -%>
2-
<% if (ui === 'vuetify') { -%>
1+
<%_ if (esm) { _%>
2+
<%_ if (ui === 'vuetify') { _%>
33
import colors from 'vuetify/es5/util/colors'
4-
<% } -%>
5-
<% } else { -%>
6-
<% if (server === 'adonis') { -%>
4+
<%_ } _%>
5+
<%_ } else { _%>
6+
<%_ if (server === 'adonis') { _%>
77
const { resolve } = require('path')
8-
<% } -%>
9-
<% if (ui === 'vuetify') { -%>
8+
<%_ } _%>
9+
<%_ if (ui === 'vuetify') { _%>
1010
const colors = require('vuetify/es5/util/colors').default
11-
<% } -%>
12-
<% } -%>
11+
<%_ } _%>
12+
<%_ } _%>
1313

14-
<% if (esm) { -%>
14+
<%_ if (esm) { _%>
1515
export default {
16-
<% } else { -%>
16+
<%_ } else { _%>
1717
module.exports = {
18-
<% } -%>
18+
<%_ } _%>
1919
mode: '<%= mode %>',
20-
<% if (server === 'adonis') { %>
20+
<%_ if (server === 'adonis') { _%>
2121
dev: process.env.NODE_ENV === 'development',
2222
srcDir: resolve(__dirname, '..', 'resources'),
23-
<% } %>
23+
<%_ } _%>
2424
/*
2525
** Headers of the page
2626
*/
2727
head: {
28-
<% if (ui === 'vuetify') { %>
28+
<%_ if (ui === 'vuetify') { _%>
2929
titleTemplate: '%s - ' + process.env.npm_package_name,
30-
<% } %>
30+
<%_ } _%>
3131
title: process.env.npm_package_name || '',
3232
meta: [
3333
{ charset: 'utf-8' },
@@ -43,62 +43,78 @@ module.exports = {
4343
}<% } %>
4444
]
4545
},
46-
4746
/*
4847
** Customize the progress-bar color
4948
*/
5049
loading: { color: '#fff' },
51-
5250
/*
5351
** Global CSS
5452
*/
55-
css: [<% if (ui === 'element-ui') { %>
56-
'element-ui/lib/theme-chalk/index.css'<% } else if (ui === 'tailwind') { %>
57-
'~/assets/css/tailwind.css'<% } else if (ui === 'iview') { %>
58-
'iview/dist/styles/iview.css'<% } else if (ui === 'ant-design-vue') { %>
59-
'ant-design-vue/dist/antd.css'<% } else if (ui === 'tachyons') { %>
60-
'tachyons/css/tachyons.css'<% } %>
53+
css: [
54+
<%_ if (ui === 'element-ui') { _%>
55+
'element-ui/lib/theme-chalk/index.css'
56+
<%_ } else if (ui === 'tailwind') { _%>
57+
'~/assets/css/tailwind.css'
58+
<%_ } else if (ui === 'iview') { _%>
59+
'iview/dist/styles/iview.css'
60+
<%_ } else if (ui === 'ant-design-vue') { _%>
61+
'ant-design-vue/dist/antd.css'
62+
<%_ } else if (ui === 'tachyons') { _%>
63+
'tachyons/css/tachyons.css'
64+
<%_ } _%>
6165
],
62-
6366
/*
6467
** Plugins to load before mounting the App
6568
*/
66-
plugins: [<% if (ui === 'element-ui') { %>
67-
'@/plugins/element-ui'<% } else if (ui === 'iview') { %>
68-
'@/plugins/iview'<% } else if (ui === 'ant-design-vue') { %>
69-
'@/plugins/antd-ui'<% } %>
69+
plugins: [
70+
<%_ if (ui === 'element-ui') { _%>
71+
'@/plugins/element-ui'
72+
<%_ } else if (ui === 'iview') { _%>
73+
'@/plugins/iview'
74+
<%_ } else if (ui === 'ant-design-vue') { _%>
75+
'@/plugins/antd-ui'
76+
<%_ } _%>
7077
],
71-
7278
/*
7379
** Nuxt.js modules
7480
*/
75-
modules: [<% if (axios === 'yes') { %>
76-
// Doc: https://axios.nuxtjs.org/usage
77-
'@nuxtjs/axios',<% } %><% if (ui === 'bootstrap') { %>
81+
modules: [
82+
<%_ if (ui === 'bootstrap') { _%>
7883
// Doc: https://bootstrap-vue.js.org/docs/
79-
'bootstrap-vue/nuxt',<% } %><% if (ui === 'bulma') { %>
84+
'bootstrap-vue/nuxt',
85+
<%_ } else if (ui === 'bulma') { _%>
8086
// Doc:https://github.com/nuxt-community/modules/tree/master/packages/bulma
81-
'@nuxtjs/bulma',<% } %><% if (ui === 'buefy') { %>
87+
'@nuxtjs/bulma',
88+
<%_ } else if (ui === 'buefy') { _%>
8289
// Doc: https://buefy.github.io/#/documentation
83-
'nuxt-buefy',<% } %><% if (pwa === 'yes') { %>
84-
'@nuxtjs/pwa',<% } %><% if (eslint === 'yes') { %>
85-
'@nuxtjs/eslint-module',<% } %><% if (ui === 'vuetify') { %>
86-
'@nuxtjs/vuetify',<% } %>
90+
'nuxt-buefy',
91+
<%_ } else if (ui === 'vuetify') { _%>
92+
'@nuxtjs/vuetify',
93+
<%_ } _%>
94+
<%_ if (axios === 'yes') { _%>
95+
// Doc: https://axios.nuxtjs.org/usage
96+
'@nuxtjs/axios',
97+
<%_ } _%>
98+
<%_ if (pwa === 'yes') { _%>
99+
'@nuxtjs/pwa',
100+
<%_ } _%>
101+
<%_ if (eslint === 'yes') { _%>
102+
'@nuxtjs/eslint-module',
103+
<%_ } _%>
87104
],
88-
<% if (axios === 'yes') { %>
105+
<%_ if (axios === 'yes') { _%>
89106
/*
90107
** Axios module configuration
91108
** See https://axios.nuxtjs.org/options
92109
*/
93110
axios: {
94-
95-
},<% } %>
96-
97-
<% if (ui === 'vuetify') { %>
98-
/*
99-
** vuetify module configuration
100-
** https://github.com/nuxt-community/vuetify-module
101-
*/
111+
},
112+
<%_ } _%>
113+
<%_ if (ui === 'vuetify') { _%>
114+
/*
115+
** vuetify module configuration
116+
** https://github.com/nuxt-community/vuetify-module
117+
*/
102118
vuetify: {
103119
theme: {
104120
primary: colors.blue.darken2,
@@ -109,26 +125,29 @@ module.exports = {
109125
error: colors.deepOrange.accent4,
110126
success: colors.green.accent3
111127
}
112-
},<% } %>
113-
128+
},
129+
<%_ } _%>
114130
/*
115131
** Build configuration
116132
*/
117-
build: {<% if (ui === 'bulma') { %>
133+
build: {
134+
<%_ if (ui === 'bulma') { _%>
118135
postcss: {
119136
preset: {
120137
features: {
121138
customProperties: false
122139
}
123140
}
124-
},<% } %><% if (ui === 'element-ui') { %>
141+
},
142+
<%_ } else if (ui === 'element-ui') { _%>
125143
transpile: [/^element-ui/],
126-
<% } %><% if (ui === 'tailwind') { %>
144+
<%_ } else if (ui === 'tailwind') { _%>
127145
postcss: {
128146
plugins: {
129147
tailwindcss: './tailwind.config.js'
130148
}
131-
}, <% } %>
149+
},
150+
<%_ } _%>
132151
/*
133152
** You can extend webpack config here
134153
*/

0 commit comments

Comments
 (0)