Skip to content

Commit

Permalink
refactor: make package and nuxt.config templates more readable
Browse files Browse the repository at this point in the history
  • Loading branch information
clarkdo committed Jun 6, 2019
1 parent 650fe6c commit 1bbe461
Show file tree
Hide file tree
Showing 4 changed files with 161 additions and 99 deletions.
125 changes: 88 additions & 37 deletions template/_package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,52 @@
"description": "<%= description %>",
"author": "<%= author %>",
"private": true,
"scripts": {<% if (server === 'adonis') { %>
"scripts": {
<%_ if (eslint === 'yes') { _%>
"lint": "eslint --ext .js,.vue --ignore-path .gitignore .",
"precommit": "<%= pm %> run lint",
<%_ } _%>
<%_ if (test !== 'none') { _%>
"test": "<%= test %>",
<%_ } _%>
<%_ if (server === 'none') { _%>
"dev": "nuxt",
"build": "nuxt build",
"start": "nuxt start",
"generate": "nuxt generate"
<%_ } else if (server === 'adonis') { _%>
"serve:dev": "<%= pm %> run dev",
"dev": "nodemon --watch app --watch bootstrap --watch config --watch .env -x node server.js",
"build": "cross-env NODE_ENV=production node ./ace nuxtbuild",
"start": "cross-env NODE_ENV=production node server.js"<% } else { %>
"dev": "<% if (server === 'none') { %>nuxt<% } else { %>cross-env NODE_ENV=development nodemon server/index.js --watch server<% } %>",
"start": "cross-env NODE_ENV=production node server.js"
<%_ } else { _%>
"dev": "cross-env NODE_ENV=development nodemon server/index.js --watch server",
"build": "nuxt build",
"start": "<% if (server === 'none') { %>nuxt start<% } else { %>cross-env NODE_ENV=production node server/index.js<% } %>",
"generate": "nuxt generate"<% } %><% if (eslint === 'yes') { %>,
"lint": "eslint --ext .js,.vue --ignore-path .gitignore .",
"precommit": "<%= pm %> run lint"<% } %><% if (test !== 'none') { %>,
"test": "<%= test %>"<% } %>
"start": "cross-env NODE_ENV=production node server/index.js",
"generate": "nuxt generate"
<%_ } _%>
},
"dependencies": {
"cross-env": "^5.2.0"<% if (edge) { %>,
"nuxt-edge": "latest"<% } else { %>,
"nuxt": "^2.0.0"<% } %><% if (server === 'express') { %>,
"express": "^4.16.4"<% } else if (server === 'koa') { %>,
"koa": "^2.6.2"<% } else if (server === 'hapi') { %>,
<%_ if (server !== 'none') { _%>
"cross-env": "^5.2.0",
<%_ } _%>
<%_ if (server === 'express') { _%>
"express": "^4.16.4",
<%_ } else if (server === 'koa') { _%>
"koa": "^2.6.2",
<%_ } else if (server === 'hapi') { _%>
"@hapi/hapi": "^18.3.1",
"@nuxtjs/hapi": "^2.2.1"<% } else if (server === 'micro') { %>,
"@nuxtjs/hapi": "^2.2.1",
<%_ } else if (server === 'micro') { _%>
"micro": "^9.3.3",
"micro-route": "^2.5.0"<% } else if (server === 'fastify') { %>,
"fastify": "^1.13.3"<% } else if (server === 'feathers') { %>,
"micro-route": "^2.5.0",
<%_ } else if (server === 'fastify') { _%>
"fastify": "^1.13.3",
<%_ } else if (server === 'feathers') { _%>
"@feathersjs/feathers": "^3.3.1",
"@feathersjs/express": "^1.3.1",
"@feathersjs/configuration": "^2.0.6"<% } else if (server === 'adonis') { %>,
"@feathersjs/configuration": "^2.0.6",
<%_ } else if (server === 'adonis') { _%>
"@adonisjs/ace": "^4.0.7",
"@adonisjs/auth": "^2.0.10",
"@adonisjs/bodyparser": "^1.0.8",
Expand All @@ -40,21 +59,47 @@
"@adonisjs/ignitor": "^1.0.14",
"@adonisjs/lucid": "^4.0.22",
"@adonisjs/session": "^1.0.19",
"@adonisjs/shield": "^1.0.4"<% } %><% if (ui === 'bootstrap') { %>,
"@adonisjs/shield": "^1.0.4",
<%_ } _%>
<%_ if (ui === 'bootstrap') { _%>
"bootstrap-vue": "^2.0.0-rc.11",
"bootstrap": "^4.1.3"<% } else if (ui === 'vuetify') { %>,
"@nuxtjs/vuetify": "0.5.5"<% } else if (ui === 'bulma') { %>,
"@nuxtjs/bulma": "^1.2.1"<% } else if (ui === 'element-ui') { %>,
"element-ui": "^2.4.11"<% } else if (ui === 'ant-design-vue') { %>,
"ant-design-vue": "^1.1.10"<% } else if (ui === 'buefy') { %>,
"nuxt-buefy": "^0.3.2"<% } else if (ui === 'iview') { %>,
"iview": "3.1.5"<% } %><% if (axios === 'yes') { %>,
"@nuxtjs/axios": "^5.3.6"<% } %><% if (pwa === 'yes') { %>,
"@nuxtjs/pwa": "^2.6.0"<% } %><% if (ui === 'tachyons') { %>,
"tachyons": "^4.11.1"<% } %>
"bootstrap": "^4.1.3",
<%_ } else if (ui === 'vuetify') { _%>
"@nuxtjs/vuetify": "0.5.5",
<%_ } else if (ui === 'bulma') { _%>
"@nuxtjs/bulma": "^1.2.1",
<%_ } else if (ui === 'element-ui') { _%>
"element-ui": "^2.4.11",
<%_ } else if (ui === 'ant-design-vue') { _%>
"ant-design-vue": "^1.1.10"
<%_ } else if (ui === 'buefy') { _%>
"nuxt-buefy": "^0.3.2",
<%_ } else if (ui === 'iview') { _%>
"iview": "3.1.5",
<%_ } _%>
<%_ if (axios === 'yes') { _%>
"@nuxtjs/axios": "^5.3.6",
<%_ } _%>
<%_ if (pwa === 'yes') { _%>
"@nuxtjs/pwa": "^2.6.0",
<%_ } _%>
<%_ if (ui === 'tachyons') { _%>
"tachyons": "^4.11.1",
<%_ } _%>
<%_ if (edge) { _%>
"nuxt-edge": "latest"
<%_ } else { _%>
"nuxt": "^2.0.0"
<%_ } _%>
},
"devDependencies": {
"nodemon": "^1.18.9"<% if (eslint === 'yes') { %>,
<%_ if (ui === 'tailwind') { _%>
"tailwindcss": "^1.0.0",
<%_ } else if (ui === 'vuetify') { _%>
"stylus": "^0.54.5",
"stylus-loader": "^3.0.2",
<%_ } _%>
<%_ if (eslint === 'yes') { _%>
"@nuxtjs/eslint-config": "^0.0.1",
"@nuxtjs/eslint-module": "^0.0.1",
"babel-eslint": "^10.0.1",
Expand All @@ -66,22 +111,28 @@
"eslint-plugin-nuxt": ">=0.4.2",
"eslint-plugin-promise": ">=4.0.1",
"eslint-plugin-standard": ">=4.0.0",
"eslint-plugin-vue": "^5.2.2"<% } %><% if (prettier === 'yes') { %>,
"eslint-plugin-vue": "^5.2.2",
<%_ } _%>
<%_ if (prettier === 'yes') { _%>
"eslint-config-prettier": "^4.1.0",
"eslint-plugin-prettier": "^3.0.1",
"prettier": "^1.16.4"<% } %><% if (ui === 'tailwind') { %>,
"tailwindcss": "^1.0.0"<% } else if (ui === 'vuetify') { %>,
"stylus": "^0.54.5",
"stylus-loader": "^3.0.2"<% } %><% if (test !== 'none') { %>,
"@vue/test-utils": "^1.0.0-beta.27"<% } %><% if (test === 'jest') { %>,
"prettier": "^1.16.4",
<%_ } _%>
<%_ if (test !== 'none') { _%>
"@vue/test-utils": "^1.0.0-beta.27",
<%_ } _%>
<%_ if (test === 'jest') { _%>
"babel-core": "7.0.0-bridge.0",
"babel-jest": "^24.1.0",
"jest": "^24.1.0",
"vue-jest": "^3.0.3"<% } %><% if (test === 'ava') { %>,
"vue-jest": "^3.0.3",
<%_ } else if (test === 'ava') { _%>
"ava": "^1.0.1",
"browser-env": "^3.2.5",
"require-extension-hooks": "^0.3.3",
"require-extension-hooks-babel": "^0.1.1",
"require-extension-hooks-vue": "^2.0.0"<% } %>
"require-extension-hooks-vue": "^2.0.0",
<%_ } _%>
"nodemon": "^1.18.9"
}
}
127 changes: 73 additions & 54 deletions template/nuxt/nuxt.config.js
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
<% if (esm) { -%>
<% if (ui === 'vuetify') { -%>
<%_ if (esm) { _%>
<%_ if (ui === 'vuetify') { _%>
import colors from 'vuetify/es5/util/colors'
<% } -%>
<% } else { -%>
<% if (server === 'adonis') { -%>
<%_ } _%>
<%_ } else { _%>
<%_ if (server === 'adonis') { _%>
const { resolve } = require('path')
<% } -%>
<% if (ui === 'vuetify') { -%>
<%_ } _%>
<%_ if (ui === 'vuetify') { _%>
const colors = require('vuetify/es5/util/colors').default
<% } -%>
<% } -%>
<%_ } _%>
<%_ } _%>

<% if (esm) { -%>
<%_ if (esm) { _%>
export default {
<% } else { -%>
<%_ } else { _%>
module.exports = {
<% } -%>
<%_ } _%>
mode: '<%= mode %>',
<% if (server === 'adonis') { %>
<%_ if (server === 'adonis') { _%>
dev: process.env.NODE_ENV === 'development',
srcDir: resolve(__dirname, '..', 'resources'),
<% } %>
<%_ } _%>
/*
** Headers of the page
*/
head: {
<% if (ui === 'vuetify') { %>
<%_ if (ui === 'vuetify') { _%>
titleTemplate: '%s - ' + process.env.npm_package_name,
<% } %>
<%_ } _%>
title: process.env.npm_package_name || '',
meta: [
{ charset: 'utf-8' },
Expand All @@ -43,62 +43,78 @@ module.exports = {
}<% } %>
]
},

/*
** Customize the progress-bar color
*/
loading: { color: '#fff' },

/*
** Global CSS
*/
css: [<% if (ui === 'element-ui') { %>
'element-ui/lib/theme-chalk/index.css'<% } else if (ui === 'tailwind') { %>
'~/assets/css/tailwind.css'<% } else if (ui === 'iview') { %>
'iview/dist/styles/iview.css'<% } else if (ui === 'ant-design-vue') { %>
'ant-design-vue/dist/antd.css'<% } else if (ui === 'tachyons') { %>
'tachyons/css/tachyons.css'<% } %>
css: [
<%_ if (ui === 'element-ui') { _%>
'element-ui/lib/theme-chalk/index.css'
<%_ } else if (ui === 'tailwind') { _%>
'~/assets/css/tailwind.css'
<%_ } else if (ui === 'iview') { _%>
'iview/dist/styles/iview.css'
<%_ } else if (ui === 'ant-design-vue') { _%>
'ant-design-vue/dist/antd.css'
<%_ } else if (ui === 'tachyons') { _%>
'tachyons/css/tachyons.css'
<%_ } _%>
],

/*
** Plugins to load before mounting the App
*/
plugins: [<% if (ui === 'element-ui') { %>
'@/plugins/element-ui'<% } else if (ui === 'iview') { %>
'@/plugins/iview'<% } else if (ui === 'ant-design-vue') { %>
'@/plugins/antd-ui'<% } %>
plugins: [
<%_ if (ui === 'element-ui') { _%>
'@/plugins/element-ui'
<%_ } else if (ui === 'iview') { _%>
'@/plugins/iview'
<%_ } else if (ui === 'ant-design-vue') { _%>
'@/plugins/antd-ui'
<%_ } _%>
],

/*
** Nuxt.js modules
*/
modules: [<% if (axios === 'yes') { %>
// Doc: https://axios.nuxtjs.org/usage
'@nuxtjs/axios',<% } %><% if (ui === 'bootstrap') { %>
modules: [
<%_ if (ui === 'bootstrap') { _%>
// Doc: https://bootstrap-vue.js.org/docs/
'bootstrap-vue/nuxt',<% } %><% if (ui === 'bulma') { %>
'bootstrap-vue/nuxt',
<%_ } else if (ui === 'bulma') { _%>
// Doc:https://github.com/nuxt-community/modules/tree/master/packages/bulma
'@nuxtjs/bulma',<% } %><% if (ui === 'buefy') { %>
'@nuxtjs/bulma',
<%_ } else if (ui === 'buefy') { _%>
// Doc: https://buefy.github.io/#/documentation
'nuxt-buefy',<% } %><% if (pwa === 'yes') { %>
'@nuxtjs/pwa',<% } %><% if (eslint === 'yes') { %>
'@nuxtjs/eslint-module',<% } %><% if (ui === 'vuetify') { %>
'@nuxtjs/vuetify',<% } %>
'nuxt-buefy',
<%_ } else if (ui === 'vuetify') { _%>
'@nuxtjs/vuetify',
<%_ } _%>
<%_ if (axios === 'yes') { _%>
// Doc: https://axios.nuxtjs.org/usage
'@nuxtjs/axios',
<%_ } _%>
<%_ if (pwa === 'yes') { _%>
'@nuxtjs/pwa',
<%_ } _%>
<%_ if (eslint === 'yes') { _%>
'@nuxtjs/eslint-module',
<%_ } _%>
],
<% if (axios === 'yes') { %>
<%_ if (axios === 'yes') { _%>
/*
** Axios module configuration
** See https://axios.nuxtjs.org/options
*/
axios: {

},<% } %>

<% if (ui === 'vuetify') { %>
/*
** vuetify module configuration
** https://github.com/nuxt-community/vuetify-module
*/
},
<%_ } _%>
<%_ if (ui === 'vuetify') { _%>
/*
** vuetify module configuration
** https://github.com/nuxt-community/vuetify-module
*/
vuetify: {
theme: {
primary: colors.blue.darken2,
Expand All @@ -109,26 +125,29 @@ module.exports = {
error: colors.deepOrange.accent4,
success: colors.green.accent3
}
},<% } %>

},
<%_ } _%>
/*
** Build configuration
*/
build: {<% if (ui === 'bulma') { %>
build: {
<%_ if (ui === 'bulma') { _%>
postcss: {
preset: {
features: {
customProperties: false
}
}
},<% } %><% if (ui === 'element-ui') { %>
},
<%_ } else if (ui === 'element-ui') { _%>
transpile: [/^element-ui/],
<% } %><% if (ui === 'tailwind') { %>
<%_ } else if (ui === 'tailwind') { _%>
postcss: {
plugins: {
tailwindcss: './tailwind.config.js'
}
}, <% } %>
},
<%_ } _%>
/*
** You can extend webpack config here
*/
Expand Down
Loading

0 comments on commit 1bbe461

Please sign in to comment.