Skip to content

Commit

Permalink
feat: add dotenv module (#358)
Browse files Browse the repository at this point in the history
  • Loading branch information
reegodev authored and clarkdo committed Nov 9, 2019
1 parent 382378d commit 40dd947
Show file tree
Hide file tree
Showing 7 changed files with 115 additions and 3 deletions.
3 changes: 2 additions & 1 deletion prompts.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ module.exports = [
pageSize: 10,
choices: [
{ name: 'Axios', value: 'axios' },
{ name: 'Progressive Web App (PWA) Support', value: 'pwa' }
{ name: 'Progressive Web App (PWA) Support', value: 'pwa' },
{ name: 'DotEnv', value: 'dotenv' }
],
default: []
},
Expand Down
7 changes: 5 additions & 2 deletions saofile.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ module.exports = {
const prettier = this.answers.linter.includes('prettier')
const lintStaged = eslint && this.answers.linter.includes('lintStaged')
const axios = this.answers.features.includes('axios')
const dotenv = this.answers.features.includes('dotenv')
const esm = this.answers.server === 'none'
const pmRun = this.answers.pm === 'yarn' ? 'yarn' : 'npm run'

Expand All @@ -27,7 +28,8 @@ module.exports = {
axios,
esm,
edge,
pmRun
pmRun,
dotenv
}
},
actions () {
Expand Down Expand Up @@ -94,7 +96,8 @@ module.exports = {
filters: {
'_.eslintrc.js': 'linter.includes("eslint")',
'.prettierrc': 'linter.includes("prettier")',
'jsconfig.json': 'devTools.includes("jsconfig.json")'
'jsconfig.json': 'devTools.includes("jsconfig.json")',
'.env': 'features.includes("dotenv")'
}
})

Expand Down
1 change: 1 addition & 0 deletions template/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
BASE_URL=http://localhost:3000
3 changes: 3 additions & 0 deletions template/_package.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@
<%_ if (pwa) { _%>
"@nuxtjs/pwa": "^3.0.0-0",
<%_ } _%>
<%_ if (dotenv) { _%>
"@nuxtjs/dotenv": "^1.4.0",
<%_ } _%>
<%_ if (ui === 'tachyons') { _%>
"tachyons": "^4.11.1",
<%_ } _%>
Expand Down
4 changes: 4 additions & 0 deletions template/nuxt/nuxt.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,10 @@ module.exports = {
<%_ if (pwa) { _%>
'@nuxtjs/pwa',
<%_ } _%>
<%_ if (dotenv) { _%>
// Doc: https://github.com/nuxt-community/dotenv-module
'@nuxtjs/dotenv',
<%_ } _%>
],
<%_ if (axios) { _%>
/*
Expand Down
100 changes: 100 additions & 0 deletions test/snapshots/index.test.js.md
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,106 @@ Generated by [AVA](https://ava.li).
}␊
`

## verify features: DotEnv

> Generated files
[
'.editorconfig',
'.env',
'.gitignore',
'README.md',
'assets/README.md',
'components/Logo.vue',
'components/README.md',
'layouts/README.md',
'layouts/default.vue',
'middleware/README.md',
'nuxt.config.js',
'package.json',
'pages/README.md',
'pages/index.vue',
'plugins/README.md',
'static/README.md',
'static/favicon.ico',
'store/README.md',
]

> package.json
{
dependencies: {
'@nuxtjs/dotenv': '^1.4.0',
nuxt: '^2.0.0',
},
devDependencies: {},
private: true,
scripts: {
build: 'nuxt build',
dev: 'nuxt',
generate: 'nuxt generate',
start: 'nuxt start',
},
}

> Generated nuxt.config.js
`␊
export default {␊
mode: 'universal',␊
/*␊
** Headers of the page␊
*/␊
head: {␊
title: process.env.npm_package_name || '',␊
meta: [␊
{ charset: 'utf-8' },␊
{ name: 'viewport', content: 'width=device-width, initial-scale=1' },␊
{ hid: 'description', name: 'description', content: process.env.npm_package_description || '' }␊
],␊
link: [␊
{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }␊
]␊
},␊
/*␊
** Customize the progress-bar color␊
*/␊
loading: { color: '#fff' },␊
/*␊
** Global CSS␊
*/␊
css: [␊
],␊
/*␊
** Plugins to load before mounting the App␊
*/␊
plugins: [␊
],␊
/*␊
** Nuxt.js dev-modules␊
*/␊
buildModules: [␊
],␊
/*␊
** Nuxt.js modules␊
*/␊
modules: [␊
// Doc: https://github.com/nuxt-community/dotenv-module␊
'@nuxtjs/dotenv',␊
],␊
/*␊
** Build configuration␊
*/␊
build: {␊
/*␊
** You can extend webpack config here␊
*/␊
extend (config, ctx) {␊
}␊
}␊
}␊
`

## verify features: Progressive Web App (PWA) Support

> Generated files
Expand Down
Binary file modified test/snapshots/index.test.js.snap
Binary file not shown.

0 comments on commit 40dd947

Please sign in to comment.