Skip to content
This repository was archived by the owner on Jan 18, 2022. It is now read-only.

How to resolve assets routes in images #290

Open
asanzdj opened this issue Jul 9, 2019 · 7 comments
Open

How to resolve assets routes in images #290

asanzdj opened this issue Jul 9, 2019 · 7 comments

Comments

@asanzdj
Copy link

asanzdj commented Jul 9, 2019

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.

@HiraveBapu
Copy link

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,
    }),

@znck
Copy link
Member

znck commented Nov 21, 2019

As @engblh suggested.

@znck znck closed this as completed Nov 21, 2019
@rdunk
Copy link

rdunk commented Feb 28, 2020

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

@djeikyb
Copy link

djeikyb commented Dec 23, 2020

@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?

@kovaletsyurii
Copy link

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

@znck znck reopened this Jan 12, 2021
@aranoe
Copy link

aranoe commented Mar 30, 2021

Doesn't work for me either.

@alexander-rodin
Copy link

the problem is relevant the me

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants