nuxt.config.js 7.1 KB

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