nuxt.config.js 7.1 KB

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