nuxt.config.js 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. const seoRouter = require("./plugins/seoRouter");
  2. const pkg = require("./package");
  3. module.exports = {
  4. mode: "universal",
  5. env: {
  6. baseUrl:
  7. process.env.NODE_ENV == "development"
  8. ? "https://dev.test.proginn.com"
  9. : "https://www.proginn.com",
  10. jishuBaseUrl:
  11. process.env.NODE_ENV == "development"
  12. ? "https://dev.test-jishuin.proginn.com"
  13. : "https://jishuin.proginn.com"
  14. },
  15. /**
  16. * 打包文件
  17. */
  18. build: {
  19. vendor: ["element-ui"]
  20. },
  21. server: {
  22. host: `0.0.0.0`,
  23. port: 3000
  24. },
  25. /*
  26. ** Headers of the page
  27. */
  28. head: {
  29. title: "程序员客栈",
  30. meta: [
  31. { charset: "utf-8" },
  32. { name: "viewport", content: "width=device-width, initial-scale=1" },
  33. { name: "applicable-device", content: "pc, mobile " },
  34. { name: "baidu-site-verification", content: "7IbkIN9Kwp" },
  35. { "http-equiv": "X-UA-Compatible", content: "IE=edge,chrome=1" },
  36. // hid: 'x', 可在页面内覆盖这里
  37. { name: "robots", content: "noindex,follow" },
  38. { name: "description", content: pkg.description },
  39. { "http-equiv": "Cache-Control", content: "no-transform" },
  40. { "http-equiv": "Cache-Control", content: "no-siteapp" }
  41. ],
  42. link: [{ rel: "icon", type: "image/x-icon", href: "/favicon.ico" }]
  43. },
  44. /*
  45. ** Customize the progress-bar color
  46. */
  47. loading: { color: "#fff" },
  48. /*
  49. ** Global CSS
  50. */
  51. css: [
  52. "@/assets/css/common.css",
  53. "@/assets/css/special.css",
  54. "swiper/dist/css/swiper.css"
  55. ],
  56. /*
  57. ** Plugins to load before mounting the App
  58. */
  59. plugins: [
  60. "plugins/common",
  61. "plugins/element",
  62. // 'plugins/http',
  63. "plugins/nuxtAxios",
  64. "plugins/deviceType",
  65. {
  66. src: "plugins/vant.js",
  67. ssr: false
  68. },
  69. {
  70. src: "plugins/rem",
  71. ssr: false
  72. },
  73. {
  74. src: "plugins/vconsole",
  75. ssr: false
  76. },
  77. {
  78. src: "plugins/vue-swiper.js",
  79. ssr: false
  80. },
  81. {
  82. src: "plugins/g2.js",
  83. ssr: false
  84. }
  85. ],
  86. /*
  87. ** Axios module configuration
  88. */
  89. axios: {
  90. // See http://github.com/nuxt-community/axios-module#options
  91. proxy: process.env.NODE_ENV === "development",
  92. // http: true,
  93. progress: true,
  94. // baseURL: process.env.BASE_URL || '',
  95. // browserBaseURL: '',
  96. timeout: 15000,
  97. credentials: true,
  98. proxyHeaders: true
  99. // debug: true
  100. },
  101. /**
  102. * Proxy
  103. */
  104. proxy: [
  105. ["/api", { target: "https://dev.test.proginn.com", changeOrigin: true }],
  106. [
  107. "/file/proxyUpload",
  108. { target: "https://dev.test.proginn.com", changeOrigin: true }
  109. ],
  110. [
  111. "/file/prepareUpload",
  112. { target: "https://dev.test.proginn.com", changeOrigin: true }
  113. ],
  114. [
  115. "/file/uploadCallback",
  116. { target: "https://dev.test.proginn.com", changeOrigin: true }
  117. ],
  118. // [ '/programmerinnfile', { target: 'https://v0.api.upyun.com', changeOrigin: true } ],
  119. [
  120. "/upload_image",
  121. { target: "https://dev.test-jishuin.proginn.com", changeOrigin: true }
  122. ],
  123. ["/image", { target: "https://stacdn.proginn.com", changeOrigin: true }]
  124. ],
  125. /*
  126. ** Nuxt.js modules
  127. */
  128. modules: ["@nuxtjs/axios", "@nuxtjs/proxy"],
  129. /*
  130. ** Build configuration
  131. */
  132. build: {
  133. /*
  134. ** You can extend webpack config here
  135. */
  136. extractCSS: {
  137. //提取html中的 css到文件
  138. splitChunks: {
  139. cacheGroups: {
  140. styles: {
  141. name: "styles",
  142. test: /\.(css|vue|scss|less)$/,
  143. chunks: "all",
  144. enforce: true
  145. }
  146. }
  147. }
  148. },
  149. optimization: {
  150. splitChunks: {
  151. chunks: "all",
  152. automaticNameDelimiter: ".",
  153. name: undefined,
  154. cacheGroups: {}
  155. }
  156. },
  157. extend(config, ctx) {
  158. config.optimization = {
  159. splitChunks: {
  160. chunks: "all",
  161. automaticNameDelimiter: ".",
  162. name: undefined,
  163. cacheGroups: {}
  164. }
  165. };
  166. //console.log(config);
  167. }
  168. },
  169. router: {
  170. middleware: "initialize",
  171. ...seoRouter
  172. }
  173. };