.cur 圖片加載提示 You may need an appropriate loader to handle this file type


最近一個gis 項目需要加載一個.cur的圖標,但是編譯時提示

You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders (Source code omitted for this binary file)

顯然是少配置了一個loader,接下來就開始配置

cli2 直接在webpack.base.config.js的module的 rules中新增如下配置即可

      {
        test: /\.(cur)(\?.*)?$/,
        loader: 'url-loader',
        options: {
          limit: 10000,
          name: utils.assetsPath('cur/[name].[hash:7].[ext]')
        }
      },

而cli3 就更簡單了,直接在vue.config.js中新增如下配置


    chainWebpack: config => {
        config.module
            .rule('url-loader')
            .test(/\.(cur)(\?.*)?$/)
            .use('url-loader')
            .loader('url-loader')
            .end()
    },
    

配置詳情可以參考官網 https://cli.vuejs.org/guide/webpack.html#adding-a-new-loader

特此記錄希望對有需要的伙伴一點幫助


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM