nuxt.config.js 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  1. // import colors from 'vuetify/es5/util/colors'
  2. // import zhHans from 'vuetify/lib/locale/zh-Hans';
  3. import dotenv from 'dotenv';
  4. // dotenv.config({
  5. // path: `.env`,
  6. // });
  7. let mode = 'development';
  8. const modeIndex = process.argv.indexOf('--mode');
  9. if (modeIndex !== -1) {
  10. mode = process.argv[modeIndex + 1];
  11. }
  12. dotenv.config({
  13. path: `.env.${mode}`,
  14. });
  15. export default {
  16. // Disable server-side rendering: https://go.nuxtjs.dev/ssr-mode
  17. ssr: false,
  18. // Global page headers: https://go.nuxtjs.dev/config-head
  19. head: {
  20. titleTemplate: '%s',
  21. title: 'android-cloud-H5-nuxt',
  22. htmlAttrs: {
  23. lang: 'zh-CN',
  24. },
  25. meta: [
  26. { charset: 'utf-8' },
  27. {
  28. hid: 'author',
  29. name: 'author',
  30. content: process.env.npm_package_author_name,
  31. },
  32. {
  33. hid: 'version',
  34. name: 'version',
  35. content: process.env.npm_package_version,
  36. },
  37. {
  38. name: 'viewport',
  39. content:
  40. 'width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no,shrink-to-fit=no,viewport-fit=cover',
  41. },
  42. {
  43. hid: 'description',
  44. name: 'description',
  45. content: process.env.npm_package_description || '',
  46. },
  47. { name: 'format-detection', content: 'telephone=no' },
  48. {
  49. hid: 'keywords',
  50. name: 'keywords',
  51. content: '双子星云手机',
  52. },
  53. ],
  54. link: [{ rel: 'icon', type: 'image/x-icon', href: '/h5/favicon.ico' }],
  55. },
  56. // Global CSS: https://go.nuxtjs.dev/config-css
  57. css: [
  58. 'normalize.css',
  59. '@mdi/font/css/materialdesignicons.css',
  60. '~/assets/style/main.scss',
  61. // 'vant/lib/index.css'
  62. ],
  63. // Plugins to run before rendering page: https://go.nuxtjs.dev/config-plugins
  64. plugins: [
  65. '~/plugins/axios',
  66. // '~/plugins/api',
  67. '~/plugins/file-upload',
  68. // '~/plugins/message',
  69. '~/plugins/error-captured',
  70. '~/plugins/user-agent',
  71. '~/plugins/native',
  72. '~/plugins/filters',
  73. '~/plugins/vue-data-dict',
  74. // '~/plugins/jweixin',
  75. // '~/plugins/umeng-datasources',
  76. // '@/plugins/vant',
  77. ],
  78. // Auto import components: https://go.nuxtjs.dev/config-components
  79. components: [
  80. '~/components',
  81. // {
  82. // path: 'vant/es',
  83. // level: 1,
  84. // pattern: '*/index.js',
  85. // ignore: ['utils/index.js'],
  86. // prefix: 'van',
  87. // },
  88. ],
  89. // Modules for dev and build (recommended): https://go.nuxtjs.dev/config-modules
  90. buildModules: [
  91. ['@nuxtjs/dotenv', { filename: `.env.${mode}` }],
  92. '@nuxtjs/style-resources',
  93. // https://go.nuxtjs.dev/eslint
  94. '@nuxtjs/eslint-module',
  95. // https://go.nuxtjs.dev/stylelint
  96. '@nuxtjs/stylelint-module',
  97. // '~/modules/unplugin-vue-components'
  98. '@aceforth/nuxt-optimized-images',
  99. '~/modules/postcss-px-to-viewport',
  100. '~/modules/vant',
  101. // https://go.nuxtjs.dev/vuetify
  102. // '@nuxtjs/vuetify',
  103. // '@nuxtjs/composition-api/module',
  104. ],
  105. // Modules: https://go.nuxtjs.dev/config-modules
  106. modules: [
  107. // https://go.nuxtjs.dev/axios
  108. '@nuxtjs/axios',
  109. '@nuxtjs/auth-next',
  110. '@unocss/nuxt',
  111. ],
  112. unocss: {
  113. uno: true,
  114. },
  115. optimizedImages: {
  116. // optimizeImagesInDev: true,
  117. },
  118. // Axios module configuration: https://go.nuxtjs.dev/config-axios
  119. axios: {
  120. proxy: process.env.NODE_ENV === 'development',
  121. // https: process.env.API_HTTPS === 'true',
  122. // // Workaround to avoid enforcing hard-coded localhost:3000: https://github.com/nuxt-community/axios-module/issues/308
  123. // baseURL: '/',
  124. },
  125. proxy: {
  126. '/api': {
  127. // target: 'http://gntest.phone.androidscloud.com:1280',
  128. target: `http${process.env.API_PORT === '443' ? 's' : ''}://${
  129. process.env.API_HOST
  130. }:${process.env.API_PORT}`,
  131. pathRewrite: {
  132. // '^/api/': ''
  133. },
  134. },
  135. '/file': {
  136. target: `http${process.env.FILE_PORT === '443' ? 's' : ''}://${
  137. process.env.FILE_HOST
  138. }:${process.env.FILE_PORT}`,
  139. pathRewrite: {
  140. '^/file/': '',
  141. },
  142. },
  143. },
  144. auth: {
  145. plugins: ['~/plugins/auth', '~/plugins/baidu-tongji'],
  146. strategies: {
  147. password: {
  148. scheme: '~/schemes/password',
  149. token: {
  150. property: 'data.token',
  151. name: 'Authorization',
  152. type: '',
  153. },
  154. user: {
  155. property: 'data',
  156. },
  157. endpoints: {
  158. login: { url: '/user/v1/client/login', method: 'post' },
  159. user: { url: '/user/v1/client/personalInfo', method: 'get' },
  160. logout: {
  161. url: '/user/v5/visitDetailed/operationVisitDetailed',
  162. method: 'post',
  163. },
  164. },
  165. },
  166. // user: {
  167. // property: 'user',
  168. // // autoFetch: true
  169. // },
  170. },
  171. },
  172. // Vuetify module configuration: https://go.nuxtjs.dev/config-vuetify
  173. // vuetify: {
  174. // defaultAssets: false,
  175. // customVariables: ['~/assets/variables.scss'],
  176. // lang: {
  177. // locales: { zhHans },
  178. // current: 'zhHans',
  179. // },
  180. // theme: {
  181. // dark: false,
  182. // // themes: {
  183. // // dark: {
  184. // // primary: colors.blue.darken2,
  185. // // accent: colors.grey.darken3,
  186. // // secondary: colors.amber.darken3,
  187. // // info: colors.teal.lighten1,
  188. // // warning: colors.amber.base,
  189. // // error: colors.deepOrange.accent4,
  190. // // success: colors.green.accent3,
  191. // // },
  192. // // },
  193. // },
  194. // },
  195. // Build Configuration: https://go.nuxtjs.dev/config-build
  196. build: {
  197. // extend(config, { isClient, loaders: { less } }) {
  198. // // console.log('🚀 ~ file: nuxt.config.js ~ line 197 ~ extend ~ less', less);
  199. // less.lessOptions = {
  200. // modifyVars: {
  201. // // 直接覆盖变量
  202. // 'text-color': '#111',
  203. // 'border-color': '#eee',
  204. // },
  205. // };
  206. // },
  207. babel: {
  208. plugins: [],
  209. },
  210. postcss: {
  211. plugins: {},
  212. },
  213. },
  214. router: {
  215. base: '/h5/',
  216. middleware: ['auth'],
  217. },
  218. styleResources: {
  219. scss: ['~/assets/style/variables.scss'],
  220. less: ['~/assets/style/variables.less'],
  221. // hoistUseStatements: true,
  222. },
  223. server: {
  224. port: 3000, // default: 3000
  225. host: '0.0.0.0', // default: localhost,
  226. timing: false,
  227. },
  228. };