nuxt.config.js 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  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. generate: {
  65. routes: ['/claimCloudPhone/0', '/claimCloudPhone/1', '/claimCloudPhone/2', '/claimCloudPhone/3', '/claimCloudPhone/4', '/claimCloudPhone/4'] // 指定动态路由
  66. },
  67. // Plugins to run before rendering page: https://go.nuxtjs.dev/config-plugins
  68. plugins: [
  69. // '~/plugins/api',
  70. // '~/plugins/file-upload',
  71. // '~/plugins/message',
  72. '~/plugins/toast',
  73. '~/plugins/error-captured',
  74. '~/plugins/user-agent',
  75. '~/plugins/native',
  76. '~/plugins/filters',
  77. '~/plugins/vue-data-dict',
  78. { src: '~/plugins/v-mask', mode: 'client' },
  79. { src: '~/plugins/vconsole', mode: 'client' },
  80. { src: '~/plugins/callapp', mode: 'client' },
  81. '~/plugins/jweixin',
  82. // '~/plugins/umeng-datasources',
  83. '@/plugins/vant',
  84. '~/plugins/common',
  85. ],
  86. // Auto import components: https://go.nuxtjs.dev/config-components
  87. components: [
  88. '~/components',
  89. // {
  90. // path: 'vant/es',
  91. // level: 1,
  92. // pattern: '*/index.js',
  93. // ignore: ['utils/index.js'],
  94. // prefix: 'van',
  95. // },
  96. ],
  97. // Modules for dev and build (recommended): https://go.nuxtjs.dev/config-modules
  98. buildModules: [
  99. ['@nuxtjs/dotenv', { filename: `.env.${mode}` }],
  100. '@nuxtjs/style-resources',
  101. // https://go.nuxtjs.dev/eslint
  102. // https://go.nuxtjs.dev/stylelint
  103. // '~/modules/unplugin-vue-components'
  104. // '@aceforth/nuxt-optimized-images',
  105. '~/modules/postcss-px-to-viewport',
  106. // '~/modules/vant',
  107. // https://go.nuxtjs.dev/vuetify
  108. '@nuxtjs/vuetify',
  109. '@unocss/nuxt',
  110. '~/modules/vee-validate',
  111. // '@nuxtjs/composition-api/module',
  112. ],
  113. // Modules: https://go.nuxtjs.dev/config-modules
  114. modules: [
  115. // https://go.nuxtjs.dev/axios
  116. '@nuxtjs/axios',
  117. '@nuxtjs/auth-next',
  118. ],
  119. unocss: {
  120. uno: true,
  121. rules: [
  122. [/^w-(\d+)rpx$/, ([, d]) => ({ width: `${d * (100 / 375)}vw` })],
  123. [/^h-(\d+)rpx$/, ([, d]) => ({ height: `${d * (100 / 375)}vw` })],
  124. ],
  125. },
  126. optimizedImages: {
  127. // optimizeImagesInDev: true,
  128. },
  129. // Axios module configuration: https://go.nuxtjs.dev/config-axios
  130. axios: {
  131. proxy: process.env.NODE_ENV === 'development',
  132. https: process.env.API_HTTPS === 'true',
  133. // // Workaround to avoid enforcing hard-coded localhost:3000: https://github.com/nuxt-community/axios-module/issues/308
  134. // baseURL: '/',
  135. },
  136. proxy: {
  137. [process.env.API_PREFIX]: {
  138. // target: 'http://gntest.phone.androidscloud.com:1280',
  139. target: `http${process.env.API_HTTPS === 'true' ? 's' : ''}://${
  140. process.env.API_HOST
  141. }:${process.env.API_PORT}`,
  142. pathRewrite: {
  143. // '^/api': ''
  144. },
  145. },
  146. '/file': {
  147. target: `http${process.env.FILE_HTTPS === 'true' ? 's' : ''}://${
  148. process.env.FILE_HOST
  149. }:${process.env.FILE_PORT}`,
  150. pathRewrite: {
  151. '^/file': '',
  152. },
  153. },
  154. },
  155. auth: {
  156. plugins: ['~/plugins/axios', '~/plugins/auth', '~/plugins/baidu-tongji'],
  157. redirect: {
  158. login: '/login',
  159. logout: '/login',
  160. callback: '/login',
  161. home: '/login',
  162. },
  163. strategies: {
  164. password: {
  165. scheme: '~/schemes/password',
  166. token: {
  167. property: 'data.token',
  168. name: 'Authorization',
  169. type: '',
  170. },
  171. user: {
  172. property: 'data',
  173. },
  174. endpoints: {
  175. login: { url: '/user/v1/client/login', method: 'post' },
  176. user: { url: '/user/v1/client/personalInfo', method: 'get' },
  177. logout: {
  178. url: '/user/v5/visitDetailed/operationVisitDetailed',
  179. method: 'post',
  180. },
  181. },
  182. },
  183. // user: {
  184. // property: 'user',
  185. // // autoFetch: true
  186. // },
  187. },
  188. cookie: false,
  189. },
  190. // Vuetify module configuration: https://go.nuxtjs.dev/config-vuetify
  191. vuetify: {
  192. defaultAssets: false,
  193. customVariables: ['~/assets/style/variables.scss'],
  194. lang: {
  195. locales: { zhHans },
  196. current: 'zhHans',
  197. },
  198. theme: {
  199. dark: false,
  200. // themes: {
  201. // dark: {
  202. // primary: colors.blue.darken2,
  203. // accent: colors.grey.darken3,
  204. // secondary: colors.amber.darken3,
  205. // info: colors.teal.lighten1,
  206. // warning: colors.amber.base,
  207. // error: colors.deepOrange.accent4,
  208. // success: colors.green.accent3,
  209. // },
  210. // },
  211. },
  212. },
  213. // Build Configuration: https://go.nuxtjs.dev/config-build
  214. build: {
  215. transpile: ['vee-validate/dist/rules'],
  216. // extend(config, { isClient, loaders: { less } }) {
  217. // // console.log('🚀 ~ file: nuxt.config.js ~ line 197 ~ extend ~ less', less);
  218. // less.lessOptions = {
  219. // modifyVars: {
  220. // // 直接覆盖变量
  221. // 'text-color': '#111',
  222. // 'border-color': '#eee',
  223. // },
  224. // };
  225. // },
  226. plugins: [
  227. // unpluginVueComponents({
  228. // resolvers: [
  229. // {
  230. // type: 'component',
  231. // resolve(componentName) {
  232. // if (componentName.startsWith('Validation')) {
  233. // console.log(
  234. // '🚀 ~ file: nuxt.config.js ~ line 230 ~ resolve ~ componentName',
  235. // componentName,
  236. // );
  237. // return {
  238. // name: componentName,
  239. // from: 'vee-validate',
  240. // // sideEffects: getSideEffects(importName, options),
  241. // };
  242. // }
  243. // },
  244. // },
  245. // ],
  246. // }),
  247. ],
  248. babel: {
  249. babelrc: false,
  250. },
  251. postcss: {
  252. plugins: {},
  253. },
  254. loaders: {
  255. vue: {
  256. transformAssetUrls: {
  257. 'v-img': 'src',
  258. },
  259. },
  260. },
  261. },
  262. router: {
  263. base: '/h5/',
  264. middleware: ['auth'],
  265. },
  266. styleResources: {
  267. scss: ['~/assets/style/variables.scss'],
  268. less: ['~/assets/style/variables.less'],
  269. // hoistUseStatements: true,
  270. },
  271. server: {
  272. port: 3000, // default: 3000
  273. host: '0.0.0.0', // default: localhost,
  274. timing: false,
  275. },
  276. };