question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Adding assets used in state or in methods in the production build

See original GitHub issue

Is your feature request related to a problem? Please describe. Am just starting out with Vue 3 using vite but I’ve not been able to find a way of having the assets used in the components state into the production build.

For example;

data() {
    return {
      testimonials: [
        {
          customer_name: "John Doe.",
          comment: "Some customer comment here...",
          image: "/src/assets/img/awesome_customer.png",
        },
        ...
      ]
    }
}

The above works in dev but the assets are not added to the production build when vite build runs and so the images throw a 404.

Describe the solution you’d like A description of how this can be achieved or a workaround for such situations. I’ve checked the asset handling section and searched around and I’ve not found a way of achieving this.

Describe alternatives you’ve considered I’ve tried using the require("/src/assets/img/awesome_customer.png") which worked with the vue-cli but the function is not defined and I can’t seem to find a way of importing it or making it available

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:9 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
geneowakcommented, Dec 21, 2020

@xiaoxian521 You can find the sample repo here demonstrating what am referring to. The readme contains the steps to reproduce.

0reactions
geneowakcommented, Jan 19, 2021

@yyx990803 thanks, is there a better approach or is importing the only way at the moment?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Asset Management - webpack
Prior to webpack, front-end developers would use tools like grunt and gulp to process these assets and move them from their /src folder...
Read more >
Asset Setup Processes (Additions) - Oracle Help Center
For Oracle Assets to recognize an asset as fully reserved when you add it, enter an accumulated depreciation amount equal to the recoverable...
Read more >
The Asset Pipeline - Ruby on Rails Guides
The asset pipeline provides a framework to concatenate and minify or compress JavaScript and CSS assets. It also adds the ability to write...
Read more >
Creating a Production Build - Create React App
npm run build creates a build directory with a production build of your app. Inside the build/static directory will be your JavaScript and...
Read more >
Fixed-Asset Accounting Basics - NetSuite
Depreciation by units of production writes off an asset according to how much that asset produces. Double Declining Balance: This method ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found