nuxt.config.js 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  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/toast',
  70. '~/plugins/error-captured',
  71. '~/plugins/user-agent',
  72. '~/plugins/native',
  73. '~/plugins/filters',
  74. '~/plugins/vue-data-dict',
  75. // '~/plugins/jweixin',
  76. // '~/plugins/umeng-datasources',
  77. // '@/plugins/vant',
  78. ],
  79. // Auto import components: https://go.nuxtjs.dev/config-components
  80. components: [
  81. '~/components',
  82. // {
  83. // path: 'vant/es',
  84. // level: 1,
  85. // pattern: '*/index.js',
  86. // ignore: ['utils/index.js'],
  87. // prefix: 'van',
  88. // },
  89. ],
  90. // Modules for dev and build (recommended): https://go.nuxtjs.dev/config-modules
  91. buildModules: [
  92. ['@nuxtjs/dotenv', { filename: `.env.${mode}` }],
  93. '@nuxtjs/style-resources',
  94. // https://go.nuxtjs.dev/eslint
  95. '@nuxtjs/eslint-module',
  96. // https://go.nuxtjs.dev/stylelint
  97. '@nuxtjs/stylelint-module',
  98. // '~/modules/unplugin-vue-components'
  99. // '@aceforth/nuxt-optimized-images',
  100. '~/modules/postcss-px-to-viewport',
  101. // '~/modules/vant',
  102. // https://go.nuxtjs.dev/vuetify
  103. '@nuxtjs/vuetify',
  104. '@unocss/nuxt',
  105. // '@nuxtjs/composition-api/module',
  106. ],
  107. // Modules: https://go.nuxtjs.dev/config-modules
  108. modules: [
  109. // https://go.nuxtjs.dev/axios
  110. '@nuxtjs/axios',
  111. '@nuxtjs/auth-next',
  112. ],
  113. unocss: {
  114. uno: true,
  115. },
  116. optimizedImages: {
  117. // optimizeImagesInDev: true,
  118. },
  119. // Axios module configuration: https://go.nuxtjs.dev/config-axios
  120. axios: {
  121. proxy: process.env.NODE_ENV === 'development',
  122. // https: process.env.API_HTTPS === 'true',
  123. // // Workaround to avoid enforcing hard-coded localhost:3000: https://github.com/nuxt-community/axios-module/issues/308
  124. // baseURL: '/',
  125. },
  126. proxy: {
  127. '/api': {
  128. // target: 'http://gntest.phone.androidscloud.com:1280',
  129. target: `http${process.env.API_PORT === '443' ? 's' : ''}://${
  130. process.env.API_HOST
  131. }:${process.env.API_PORT}`,
  132. pathRewrite: {
  133. // '^/api/': ''
  134. },
  135. },
  136. '/file': {
  137. target: `http${process.env.FILE_PORT === '443' ? 's' : ''}://${
  138. process.env.FILE_HOST
  139. }:${process.env.FILE_PORT}`,
  140. pathRewrite: {
  141. '^/file/': '',
  142. },
  143. },
  144. },
  145. auth: {
  146. plugins: ['~/plugins/auth', '~/plugins/baidu-tongji'],
  147. strategies: {
  148. password: {
  149. scheme: '~/schemes/password',
  150. token: {
  151. property: 'data.token',
  152. name: 'Authorization',
  153. type: '',
  154. },
  155. user: {
  156. property: 'data',
  157. },
  158. endpoints: {
  159. login: { url: '/user/v1/client/login', method: 'post' },
  160. user: { url: '/user/v1/client/personalInfo', method: 'get' },
  161. logout: {
  162. url: '/user/v5/visitDetailed/operationVisitDetailed',
  163. method: 'post',
  164. },
  165. },
  166. },
  167. // user: {
  168. // property: 'user',
  169. // // autoFetch: true
  170. // },
  171. },
  172. cookie: false,
  173. },
  174. // Vuetify module configuration: https://go.nuxtjs.dev/config-vuetify
  175. vuetify: {
  176. defaultAssets: false,
  177. customVariables: ['~/assets/style/variables.scss'],
  178. lang: {
  179. locales: { zhHans },
  180. current: 'zhHans',
  181. },
  182. theme: {
  183. dark: false,
  184. // themes: {
  185. // dark: {
  186. // primary: colors.blue.darken2,
  187. // accent: colors.grey.darken3,
  188. // secondary: colors.amber.darken3,
  189. // info: colors.teal.lighten1,
  190. // warning: colors.amber.base,
  191. // error: colors.deepOrange.accent4,
  192. // success: colors.green.accent3,
  193. // },
  194. // },
  195. },
  196. },
  197. // Build Configuration: https://go.nuxtjs.dev/config-build
  198. build: {
  199. // extend(config, { isClient, loaders: { less } }) {
  200. // // console.log('🚀 ~ file: nuxt.config.js ~ line 197 ~ extend ~ less', less);
  201. // less.lessOptions = {
  202. // modifyVars: {
  203. // // 直接覆盖变量
  204. // 'text-color': '#111',
  205. // 'border-color': '#eee',
  206. // },
  207. // };
  208. // },
  209. babel: {
  210. plugins: [],
  211. },
  212. postcss: {
  213. plugins: {},
  214. },
  215. loaders: {
  216. vue: {
  217. transformAssetUrls: {
  218. 'v-img': 'src',
  219. },
  220. },
  221. },
  222. },
  223. router: {
  224. base: '/h5/',
  225. middleware: ['auth'],
  226. },
  227. styleResources: {
  228. scss: ['~/assets/style/variables.scss'],
  229. less: ['~/assets/style/variables.less'],
  230. // hoistUseStatements: true,
  231. },
  232. server: {
  233. port: 3000, // default: 3000
  234. host: '0.0.0.0', // default: localhost,
  235. timing: false,
  236. },
  237. };