国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

如何配置 Vite 存取公共資料夾之外的檔案?
P粉132730839
P粉132730839 2024-04-02 12:39:53
0
1
796

我有這個(gè)檔案結(jié)構(gòu):

  • 我的項(xiàng)目
    • 應(yīng)用程式
    • 引導(dǎo)程式
    • 配置
    • 資料庫(kù)
    • 節(jié)點(diǎn)模組
      • pdfjs-dist
        • 構(gòu)建
          • pdf.js
    • 公開(kāi)
      • 上傳
        • 文件
          • solution_12.pdf
    • 資源

有人可以幫我知道如何透過(guò)設(shè)定 Vite 來(lái)存取 pdf.js 嗎?

我嘗試過(guò):

在vite.config.js中,匯出預(yù)設(shè)的defineConfig:

plugins: [
        laravel({
            input: [
                'node_modules/pdfjs-dist/build/pdf.js'
            ],
            refresh: true,
        }),
    ],

我在我的 app.blade.php 中使用了 @vite:

@vite([
    'node_modules/pdfjs-dist/build/pdf.js'
    ])

我得到了這個(gè)錯(cuò)誤: 無(wú)法在 Vite 清單中找到檔案:node_modules/pdfjs-dist/build/pdf.js。

誰(shuí)能幫我解釋一下嗎?

P粉132730839
P粉132730839

全部回覆(1)
P粉321676640

從你的問(wèn)題中我看出你似乎正在使用 Laravel(很好,因?yàn)槲乙埠苁煜ぃ?

我建議您查看 Laravel 文檔,特別是新安裝 Laravel 時(shí)開(kāi)箱即用的 vite 配置。透過(guò)遵循他們指定的目錄約定,您將避免嘗試打破他們的模式而帶來(lái)無(wú)盡的麻煩。查看 Laravel 文件的以下部分將是一個(gè)很好的起點(diǎn): https://laravel.com/docs/10.x/vite#main-內(nèi)容

#在理想的世界中,您將遵循Laravel 假設(shè)的相同約定...即您的專案有一個(gè)resources/js 資料夾,這是您通常儲(chǔ)存專案的javascript 的位置(例如app例如.js)。

只要您在應(yīng)用程式中需要的地方導(dǎo)入javascript 文件,最好的解決方案可能是使用resources/js/app.js 作為您的Vite“輸入”,並在Vite Blade 指令中引用它好吧(如resources/js/app.js)。然後,Vite 將在您的應(yīng)用程式需要時(shí)匯入該依賴項(xiàng)。

# Your vite.config.js excerpt would look like:

plugins: [
    laravel({
        input: [
            'resources/js/app.js'
        ],
        refresh: true,
    }),
],

# Your @vite blade directive would look like:

@vite(['resources/js/app.js'])

# Your import call (wherever you're using this dependency) might look like:

import 'pdfjs-dist/build/pdf.js';

希望有幫助!

最新下載
更多>
網(wǎng)站特效
網(wǎng)站源碼
網(wǎng)站素材
前端模板