nuxt.config.js 3.8 KB

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