Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

280
Views
Vue CLI build target lib -> externalize images (Vue 3)

I have a question regarding vue-cli's target build lib. I have an app that produces a custom element following this documentation. Check:

/* ce.js */
import { defineCustomElement } from 'vue';
import Chat from './App.ce.vue';
const element = defineCustomElement(Chat);
customElements.define('chat-widget', element);

The build command looks as follows:

/* package.json */
"build-wc": "vue-cli-service build --target lib --inline-vue --name chat-widget --dest ./wwwroot src/ce.js"

This is actually working all fine but not exactly how i want it. My images are all generated inline which totally bloats my generated umd file. Also when i put my app on a server it refuses to load the images when inline because of Content-Security-Policy issues (another discussion).

Is there a way to tell webpack / vue-cli that I want my images in separate folder? Preferably in the destination folder under /img.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Figured it out! Just set the maxSize of the image parser to very low and the images will be dropped in /img in the output folder. Cheers!

const { defineConfig } = require("@vue/cli-service");
module.exports = defineConfig({
    ...
    chainWebpack: (config) => {
        ...
        config.module.rule("images").set("parser", {
            dataUrlCondition: {
                maxSize: 4 * 1024, // 4KiB
            },
        });
        ...
    },
});
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!