问题
I am building an SSR nuxt.js
project with laravel backend, and I want to share the .env
for both laravel and nuxt.
Here is my folder structure (base on a laravel folder structure but add a client folder to put nuxt)
here is my nuxt.config.js
module.exports = {
srcDir: __dirname,
buildModules: [
[
'@nuxtjs/dotenv',
{
path: '../'
}
]
]
}
package.json
{
"private": true,
"scripts": {
"dev": "node_modules/nuxt/bin/nuxt.js -c client/nuxt.config.js",
"build": "node_modules/nuxt/bin/nuxt.js build -c client/nuxt.config.js",
"start": "node_modules/nuxt/bin/nuxt.js start -c client/nuxt.config.js",
"lint": "eslint --fix --ext .js,.vue client/",
"prod": "npm run build && npm run start"
},
"config": {
"nuxt": {
"host": "0.0.0.0",
"port": "3000"
}
},
"dependencies": {
"@nuxtjs/dotenv": "^1.4.1",
"nuxt": "^2.12.2",
}
}
I want to use a relative path instead of an absolute path, but it doesn't work.
How can I fix it? Thanks a lot (^_^)
来源:https://stackoverflow.com/questions/61337535/relative-path-in-nuxtjs-dotenv