nuxt.config.js 7.2 KB

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