rollup-plugin-vue icon indicating copy to clipboard operation
rollup-plugin-vue copied to clipboard

How to resolve assets routes in images

Open asanzdj opened this issue 5 years ago • 7 comments

Version

5.0.0

Reproduction link

https://codesandbox.io/embed/vue-template-3qsli

Steps to reproduce

Try the library: https://www.npmjs.com/package/daas-components

What is expected?

I'm trying to create a components library with rollup and vue, I have components with images storaged in an assets folder.

Objective:: When library is used in a project, images must be loaded.

What is actually happening?

Images are concatenating the app url path in their own path.

Resulted images::

Request URL: http://localhost:8080/APP_ROUTE/ROUTE_IM_TRYING/close.svg


I read about transformAssetUrls(https://rollup-plugin-vue.vuejs.org/options.html#template-transformasseturls) but I can't understand what is its objective and how is used.

asanzdj avatar Jul 09 '19 12:07 asanzdj

I had same issue, and tried multiple ways to solve it. rollup-plugin-asset-url was life saver.

in rollup.config.js

import url from 'rollup-plugin-asset-url'

plugins:

    url({
      limit: 5 * 1024, // inline files < 5k, copy files > 5k
      include: ['**/*.png', '**/*.ttf'],
      fileName: '[name][extname]',
      output: './static/',
      reserveImportInJs: true,
    }),

HiraveBapu avatar Sep 20 '19 14:09 HiraveBapu

As @engblh suggested.

znck avatar Nov 21 '19 16:11 znck

@asanzdj Did you find a solution for this? The suggested one here doesn't seem to work for me.

rdunk avatar Feb 28 '20 14:02 rdunk

@znck can this be reopened? There is no comment from an account named engblh. Maybe the name changed or the comment was deleted? I have zero knowledge of rollup. I'm so newb I can't tell the difference between rollup knowledge and rollup-plugin-vue knowledge. How could someone familiar with creating and maintaining a vuejs 2.6 app – but not rollup or webpack etc – use this plugin to extract some single file components along with their static assets to a reusable component library?

djeikyb avatar Dec 23 '20 02:12 djeikyb

I had same issue, and tried multiple ways to solve it. rollup-plugin-asset-url was life saver.

in rollup.config.js

import url from 'rollup-plugin-asset-url'

plugins:

    url({
      limit: 5 * 1024, // inline files < 5k, copy files > 5k
      include: ['**/*.png', '**/*.ttf'],
      fileName: '[name][extname]',
      output: './static/',
      reserveImportInJs: true,
    }),

Not working for me

kovaletsyurii avatar Jan 12 '21 12:01 kovaletsyurii

Doesn't work for me either.

aranoe avatar Mar 30 '21 11:03 aranoe

the problem is relevant the me

alexander-rodin avatar May 06 '21 11:05 alexander-rodin