Answer the question
In order to leave comments, you need to log in
How to overcome the "ReferenceError: process is not defined" error in production?
There is an SSR application on NuxtJS. The plugin "@nuxtjs/dotenv" is used.
I use it in nuxt.config.js:
require('dotenv').config(".env");
/* ---*/
axios: {
baseURL: process.env.baseUrl,
},
/* ---*/
const process = require('process');
require('dotenv').config(".env");
module.exports = {
head: {
title: 'Заголовок сайта',
meta: [
{ charset: 'utf-8' },
{ name: 'viewport', content: 'width=device-width, initial-scale=1' },
{ hid: 'description', name: 'description', content: 'Nuxt.js project' }
],
link: [
{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' },
{ rel:'Roboto', href:'https://fonts.googleapis.com/css?family=Roboto:400,700&subset=cyrillic'}
]
},
css: [
'@fortawesome/fontawesome-svg-core/styles.css',
'swiper/dist/css/swiper.css'
],
/*
** Customize the progress bar color
*/
loading: { color: '#3B8070' },
plugins: [
'@/plugins/global.js',
'@/plugins/font-awesome.js',
'@/plugins/axios.js',
'@/plugins/notifier.js',
'@/plugins/vee-validate.js',
{src: '@/plugins/swiper.js', ssr: false},
{src: '@/plugins/localStorage.js', ssr: false},
{src: '@/plugins/datepicker.js', ssr: false},
],
modules: [
'@nuxtjs/style-resources',
'@nuxtjs/router',
'@nuxtjs/axios',
'@nuxtjs/toast',
['@nuxtjs/dotenv', { systemvars: true }]
],
styleResources: {
sass: ['@assets/css/app.scss'],
},
toast: {
position: 'top-right',
duration: 3500,
},
axios: {
baseURL: process.env.baseUrl,
credentials : true,
requestInterceptor: (config, {store}) => {
config.headers.common['Authorization'] = '';
config.headers.common['Content-Type'] = 'application/x-www-form-urlencoded;application/json';
return config
}
},
/*
** Build configuration
*/
build: {
/*
** Run ESLint on save
*/
extend (config, { isDev, isClient }) {
if (isDev && isClient) {
config.module.rules.push({
enforce: 'pre',
test: /\.(js|vue)$/,
loader: 'eslint-loader',
exclude: /(node_modules)/
})
}
},
optimization: {
splitChunks: {
chunks: 'all',
automaticNameDelimiter: '.',
name: true,
cacheGroups: {},
minSize: 100000,
maxSize: 250000
}
},
maxChunkSize: 250000,
extractCSS: true
},
dev:{
extractCSS: true
}
};
Answer the question
In order to leave comments, you need to log in
Cant with the assembly, probably a piece for node.js gets into the assembly for the client, or if the webpack define plugin is used, then the values \u200b\u200bin the config for the prod version are not written there.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question