简体   繁体   English

Quasar CLI:设置配置文件 quasar.conf.js

[英]Quasar CLI: Setting the configuration file quasar.conf.js

I am new to Laravel and Quasar and I have been trying to integrate.我是 Laravel 和 Quasar 的新手,我一直在尝试整合。

I have the backend part ready just for some simple testing.我已经准备好了后端部分,只是为了一些简单的测试。

My frontend is ready as well.我的前端也准备好了。

The only problem I am having is with the configuration file of quasar.我遇到的唯一问题是 quasar 的配置文件。

I tried to set it the same way as this project: https://github.com/yyx990803/laravel-vue-cli-3我尝试以与该项目相同的方式设置它: https : //github.com/yyx990803/laravel-vue-cli-3

But, the api doesn't get the data.但是,api 没有获取数据。

This is my configuration code.这是我的配置代码。

quasar.conf.js类文件配置文件

module.exports = function(/* ctx */) {
  return {
    supportTS: false,

    boot: ["i18n", "axios"],

    css: ["app.sass"],

    extras: ["roboto-font", "material-icons"],

    build: {
      vueRouterMode: "history",

      extendWebpack(cfg) {
        cfg.module.rules.push({
          enforce: "pre",
          test: /\.(js|vue)$/,
          loader: "eslint-loader",
          exclude: /node_modules/
        });
      }
    },

    devServer: {
      https: false,
      port: 8080,
      open: true,
      proxy: {
        
        "/api": {
          target: "http:
          changeOrigin: true,
          pathRewrite: {
            "^/api": ""
          }
        }
      } 
    },

    framework: {
      iconSet: "material-icons",
      lang: "en-us",
      config: {},

      importStrategy: "auto",

      plugins: []
    },

    animations: [],

    ssr: {
      pwa: false
    },

    pwa: {
      workboxPluginMode: "GenerateSW",
      workboxOptions: {},
      manifest: {
        name: `Quasar App`,
        short_name: `Quasar App`,
        description: `A Quasar Framework app`,
        display: "standalone",
        orientation: "portrait",
        background_color: "#ffffff",
        theme_color: "#027be3",
        icons: [
          {
            src: "icons/icon-128x128.png",
            sizes: "128x128",
            type: "image/png"
          },
          {
            src: "icons/icon-192x192.png",
            sizes: "192x192",
            type: "image/png"
          },
          {
            src: "icons/icon-256x256.png",
            sizes: "256x256",
            type: "image/png"
          },
          {
            src: "icons/icon-384x384.png",
            sizes: "384x384",
            type: "image/png"
          },
          {
            src: "icons/icon-512x512.png",
            sizes: "512x512",
            type: "image/png"
          }
        ]
      }
    },

    cordova: {},

    capacitor: {
      hideSplashscreen: true
    },

    electron: {
      bundler: "packager",

      packager: {},

      builder: {
        appId: "frontend"
      },

      nodeIntegration: true,

      extendWebpack(/* cfg */) {}
    }
  };
};

Here's a guide on how to setup Quasar + Laravel to get a working PWA with API endpoint on mydomain.com/api这是有关如何设置 Quasar + Laravel 以在mydomain.com/api上使用 API 端点获取工作 PWA 的指南

https://dreamonkey.com/en/blog/how-to-setup-a-pwa-with-quasar-and-laravel/ https://dreamonkey.com/en/blog/how-to-setup-a-pwa-with-quasar-and-laravel/

Check if it can be useful for your use case.检查它是否对您的用例有用。 It expects you to be working with Homestead in your local machine and managing authentication with Laravel Sanctum.它希望您在本地机器上使用 Homestead,并使用 Laravel Sanctum 管理身份验证。

This snippet in particular:特别是这个片段:

module.exports = configure(function(ctx) {
  return {
    // Other configure options
    // Full list of options: https://quasar.dev/quasar-cli/quasar-conf-js#Property%3A-devServer
    devServer: {
      https: false,
      port: 8080,
      open: true, // opens browser window automatically
      proxy: [
        {
          context: ['/sanctum', '/login', '/password', '/logout', '/api'],
          target: 'http://192.168.10.10', // Laravel Homestead end-point
          // avoid problems with session and XSRF cookies
          // When using capacitor, use the IP of the dev server streaming the app
          // For SPA and PWA use localhost, given that the app is streamed on that host
          // xxx address is the IP address chosen by Quasar to stream the app
          cookieDomainRewrite:
            ctx.modeName === 'capacitor' ? 'xxx.xxx.xxx.xxx' : 'localhost'
        }
      ]
    },
  }
});

If it doesn't work, you may have some errors in the code making the async requests如果它不起作用,您可能在发出异步请求的代码中存在一些错误

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM