| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282 |
- 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("<style(([\\s\\S])*?)<\\/style>", "igm");
- let match = html.match(htmlRegx);
- if (match) {
- html = html.replace(htmlRegx, "");
- match.forEach((item, index) => {
- html = html.replace(/<\/body>/, item + "</body>");
- });
- }
- 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("</body>") - 100));
- page.html = modifyHtml(page.html);
- // console.log(page.html.substring(page.html.indexOf("</body>") - 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
- }
- };
|