const seoRouter = require("./plugins/seoRouter"); const pkg = require("./package"); if (process.env.NODE_ENV) { require("events").EventEmitter.defaultMaxListeners = 50; } const modifyHtml = html => { let htmlRegx = new RegExp("", "igm"); let match = html.match(htmlRegx); if (match) { html = html.replace(htmlRegx, ""); match.forEach((item, index) => { html = html.replace(/<\/body>/, item + ""); }); } return html; }; module.exports = { mode: "universal", buildDir: (process.env.NODE_ENV !== "development" && process.env.NODE_ENV !== "prod_test")?".nuxt":".nuxt_dev", watchers: { ignored: [".nuxt/**", "node_modules/**"], webpack: { watchOptions: { ignored: [".nuxt/**", "node_modules/**"] } } }, vue: { config: { productionTip: process.env.NODE_ENV !== "development", devtools: process.env.NODE_ENV === "development" } }, env: { NODE_ENV: process.env.NODE_ENV || 'production', baseUrl: process.env.NODE_ENV == "development" ? "https://dev.test.proginn.com" : "https://www.proginn.com", jishuBaseUrl: process.env.NODE_ENV == "development" ? "https://dev.test-jishuin.proginn.com" : "https://jishuin.proginn.com" }, /** * 打包文件 */ build: { extractCSS: true, resourceHints: true, optimization: { splitChunks: { minSize: 30000, maxSize: 1000000 } }, // publicPath: process.env.NODE_ENV === 'production' ? 'https://stacdn.proginn.com/nuxt/' : '/_nuxt/', publicPath: 'https://inn.proginn.com/client20260205/' }, hooks: { // This hook is called before rendering the html to the browser "render:route": (url, page, {req, res}) => { // console.log(page.html.substring(page.html.indexOf("") - 100)); page.html = modifyHtml(page.html); // console.log(page.html.substring(page.html.indexOf("") - 100)); } }, server: { host: `0.0.0.0`, port: 3000 }, /* ** Headers of the page */ head: { title: "程序员客栈", meta: [ { charset: "utf-8" }, { name: "viewport", content: "width=device-width, initial-scale=1" }, { name: "applicable-device", content: "pc, mobile " }, { "http-equiv": "X-UA-Compatible", content: "IE=edge,chrome=1" }, // hid: 'x', 可在页面内覆盖这里 // { // name: "robots", // content: "noindex,follow" // }, // { // name: "description", // content: pkg.description // }, { "http-equiv": "Cache-Control", content: "no-transform" }, { "http-equiv": "Cache-Control", content: "no-siteapp" } ], link: [ { rel: "shortcut icon", type: "image/vnd.microsoft.icon", href: "https://stacdn.proginn.com/favicon_new.ico" } ], }, /* ** Customize the progress-bar color */ loading: { color: '#2487ff', continuous: true }, /* ** Global CSS */ css: [ "@/assets/css/common.css", "@/assets/css/special.css", "swiper/dist/css/swiper.css", ], /* ** Plugins to load before mounting the App */ plugins: [ "plugins/common", "plugins/element", "plugins/nuxtAxios", "plugins/deviceType", "plugins/vant", "plugins/router", { src: "plugins/vant.js", ssr: false }, { src: "plugins/rem", ssr: false }, { src: "plugins/vconsole", ssr: false }, { src: "plugins/vue-swiper.js", ssr: false }, { src: "plugins/g2.js", ssr: false }, { src: 'plugins/vueLazyLoad', ssr: false }, { src: '~/plugins/cropper', ssr: false }, { src: 'plugins/directive.js', ssr: false }, { src: 'plugins/cnzz.js', ssr: false } ], /* ** Axios module configuration */ axios: { // See http://github.com/nuxt-community/axios-module#options proxy: process.env.NODE_ENV === "development", // http: true, progress: true, // baseURL: process.env.BASE_URL || '', // browserBaseURL: '', timeout: 15000, credentials: true, proxyHeaders: true // debug: true }, /** * Proxy */ proxy: [ // ["/api", { target: "https://web.test.proginn.com", changeOrigin: true }], [ "/api", { target: "https:/dev.test.proginn.com", changeOrigin: true } ], [ "/list", { target: "https://dev.test-jishuin.proginn.com", changeOrigin: true } ], [ "/file/proxyUpload", { target: "https://dev.test.proginn.com", changeOrigin: true } ], [ "/file/prepareUpload", { target: "https://dev.test.proginn.com", changeOrigin: true } ], [ "/file/uploadCallback", { target: "https://dev.test.proginn.com", changeOrigin: true } ], // [ '/programmerinnfile', { target: 'https://v0.api.upyun.com', changeOrigin: true } ], [ "/upload_image", { target: "http://dev.test.proginn.com", changeOrigin: true } ], [ "/image", { target: "https://stacdn.proginn.com", changeOrigin: true } ] ], buildModules: [ '@nuxt/typescript-build', ['@nuxtjs/router', { path: 'router', fileName: 'index.js', keepDefaultRouter: true, }] ], /* ** Nuxt.js modules */ modules: [ "@nuxtjs/axios", "@nuxtjs/proxy", ], router: { middleware: ["initialize"], ...seoRouter } };