nuxt.config.js 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. // 运行环境
  2. const envConfig = require('dotenv').config({
  3. path: `.env${process.env.ENV ? `.${process.env.ENV}` : ''}`,
  4. })
  5. export default {
  6. router: {
  7. middleware: 'auth',
  8. },
  9. // Global page headers: https://go.nuxtjs.dev/config-head
  10. head: {
  11. title: '认证通',
  12. htmlAttrs: {
  13. lang: 'zh-cn',
  14. },
  15. meta: [
  16. { charset: 'utf-8' },
  17. { name: 'viewport', content: 'width=device-width, initial-scale=1' },
  18. { name: 'description', content: '认证通|一款专业的正品认证SaaS软件系统' },
  19. { name: 'format-detection', content: 'telephone=no' },
  20. ],
  21. // link: [{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }],
  22. },
  23. // Global CSS: https://go.nuxtjs.dev/config-css
  24. css: ['vant/lib/index.css', 'swiper/css/swiper.css', '@/styles/global.css'],
  25. // Plugins to run before rendering page: https://go.nuxtjs.dev/config-plugins
  26. plugins: [
  27. '@/plugins/vant',
  28. '@/plugins/axios',
  29. '@/plugins/vue-filters',
  30. '@/plugins/storage',
  31. ],
  32. // Auto import components: https://go.nuxtjs.dev/config-components
  33. components: true,
  34. // Modules for dev and build (recommended): https://go.nuxtjs.dev/config-modules
  35. buildModules: [
  36. // https://go.nuxtjs.dev/tailwindcss
  37. '@nuxtjs/tailwindcss',
  38. ],
  39. // Modules: https://go.nuxtjs.dev/config-modules
  40. modules: [
  41. // https://go.nuxtjs.dev/axios
  42. '@nuxtjs/axios',
  43. ],
  44. // Axios module configuration: https://go.nuxtjs.dev/config-axios
  45. axios: {
  46. // Workaround to avoid enforcing hard-coded localhost:3000: https://github.com/nuxt-community/axios-module/issues/308
  47. baseURL: envConfig.parsed.BASE_URL,
  48. },
  49. // Build Configuration: https://go.nuxtjs.dev/config-build
  50. build: {
  51. extractCSS: true,
  52. filenames: {
  53. chunk: ({ isDev }) => (isDev ? '[name].js' : '[id].[contenthash].js'),
  54. },
  55. },
  56. // 配置 Nuxt.js 应用是开发模式还是生产模式
  57. dev: process.env.NODE_ENV !== 'production',
  58. // 配置在客户端和服务端共享的环境变量
  59. env: {
  60. ...process.env,
  61. ...envConfig.parsed,
  62. },
  63. server: {
  64. port: process.env.PORT,
  65. host: process.env.HOST,
  66. },
  67. }