😅😅GIT地址;
https://gitee.com/lingtin/common_template_admin

ecosystem.config


module.exports = {
    "apps": [{
        "name": "mp",
        "script": "server/index.js",
        "log_date_format": "YYYY-MM-DD HH:mm:ss",
        "error_file": "log/node-app/node-app.error.log",
        "out_file": "log/node-app.out.log",
        "instances": 3,
        "min_uptime": "1000s",
        "max_restarts": 30,
        "max_memory_restart": "1G",
        "merge_logs": false,
        "exec_mode": "cluster_mode",
        "autorestart": true,
        "vizion": false,
        "exec_interpreter": "node",
        "env": {
            "NODE_ENV": "production" // 环境变量,object类型,如{"NODE_ENV":"production", "ID": "42"};
        },
        "env_production": {
            "NODE_ENV": "production",
        }
    }]
}

nuxt.config


const PUR = process.env.npm_package_config_nuxt_base_url;

const base_url = process.env.NODE_ENV != 'development' ? PUR : 'http://192.168.0.125:8074/'

console.log('base_url:' + base_url)

const proxy_url = process.env.NODE_ENV != 'development' ? base_url : "/api";

const webmp = process.env.npm_package_config_nuxt_webmp;

console.log('spa:' + process.env.NODE_MODE)
console.log('NODE_ENV:' + process.env.NODE_ENV)

module.exports = {
    mode: process.env.NODE_MODE ? 'spa' : '',

    /*
    
     ** Headers of the page
     */

    head: {
        title: "",
        meta: [{
                charset: 'utf-8'
            },
            {
                name: 'viewport',
                content: 'width=device-width, initial-scale=1'
            },
            {
                hid: 'description',
                name: 'description',
                content: ""
            }
        ],
        link: [{
            rel: 'icon',
            type: 'image/x-icon',
            href: '/favicon.ico'
        }]
    },

    /*
     ** Customize the progress-bar color
     */
    loading: {
        color: '#3399ff'
    },
    pageTransition: "bounce",
    /*
     ** Global CSS
     */
    css: [
        'iview/dist/styles/iview.css',
        '@/static/styles/comm.css'
    ],

    /*
     ** Plugins to load before mounting the App
     */
    plugins: [
        '@/plugins/iview',
        '@/plugins/defa',
        '@/plugins/storage',
        '@/plugins/axios',
        '@/plugins/apis/user',
        '@/plugins/apis/sys',
        { src: '@/plugins/validate', mode: 'client' },
        { src: '@/plugins/auth', mode: 'client' }
    ],

    /*
     ** Nuxt.js modules
     */
    env: {
        baseUrl: base_url
    },
    modules: [
        // Doc: https://axios.nuxtjs.org/usage
        '@nuxtjs/axios',
        '@nuxtjs/moment'
    ],
    moment: {
        locales: ['es-us']
    },
    /*
     ** Axios module configuration
     */
    axios: {
        proxy: true, // Can be also an object with default options
        baseURL: proxy_url,
        browserBaseURL: proxy_url,
    },
    proxy: {
        '/api/': {
            target: base_url,
            pathRewrite: {
                '^/api': ''
            }
        },
        '/public': {
            target: base_url,
            pathRewrite: {
                '^/public': '/public/'
            }
        }

    },

    router: {
        // 在每页渲染前运行 middleware/user-agent.js 中间件的逻辑
        middleware: ['user-agent', 'auth'],
        // 所有页面渲染后滚动至顶部
        scrollBehavior: function(to, from, savedPosition) {
            return {
                // x: 0,
                y: 0
            }
        },
        // 扩展自定义路由
        extendRoutes(routes, resolve) {
            routes.push({
                name: '404',
                path: '*',
                component: resolve(__dirname, 'pages/Error/404.vue')
            })
        },
        base: process.env.NODE_MODE ? `/${webmp}/` : ''
    },


    /*
     ** Build configuration
     */
    build: {
        /*
         ** You can extend webpack config here
         */
        extend(config, ctx) {},
        terser: {
            sourceMap: false,
        }
    },
    buildDir: 'nuxt-dist',
    generate: {
        dir: webmp
    },
}