Settings for the packaging of web components

Is there a way to configure a web component in vue.config.js and separate the iconfont.css section when building?

I am using the

vue-cli-service build --target wc-async --name chat-ui src/views/Chat/Launcher.vue --report

command to package the web component. How can I customize the settings in vue.config.js for this process?

Answer №1

When working on a project, I found it helpful to customize the settings in vue.config.js for packaging a web component and extracting a separate section of iconfont.css. By utilizing the configureWebpack option, you can easily achieve this functionality. Take a look at the code snippet below for an example:

// vue.config.js
module.exports = {
configureWebpack: (config) => {

// Additional webpack configuration
if (process.env.NODE_ENV === 'production') {

// Customize production build
// Separate section of iconfont.css extraction
  config.optimization.splitChunks.cacheGroups.styles = {
    name: 'iconfont',
    test: /[\\/]node_modules[\\/].*iconfont\.css$/,
    chunks: 'all',
    enforce: true,
  };
}
},
};

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Struggling to navigate the world of Nuxtjs and graphql

Having trouble with v-for and iterating through nested objects in Nuxtjs, Strapi, and GraphQL Received this object from GraphQL: "fotografies": { "data": [ { "id": "1", "attributes&qu ...

Discovering the largest element within a group to establish the height for the rest

There is a component mapping card elements that look like this: https://i.stack.imgur.com/CktsE.png The topmost, leftmost card appears to be missing some height compared to others. Is there a way to determine the height of the tallest components and then ...

Advantages of incorporating lazy loading in a Vue Single Page Application:

What level of realistic benefit can be expected from lazy loading in a Vue application using Vue-router, Vuex, and many components to improve initial load times in an SPA? In comparison to minifying and bundling code (in this case, with gulp), do the perf ...

After uploading the WordPress theme, the wp_enqueue_style() function fails to work properly

I recently developed a new WordPress theme and encountered an issue while trying to load specific stylesheets for my child sites using the is_page(array('')) function in my function.php file. Surprisingly, only the files that were added to all of ...

Getting the next sibling element with Selenium: A complete guide

Having trouble targeting a textbox after the label "First Name" in a list to enter a first name. Here's what I've tried: WebElement firstNameLocTry = driver.findElement(By.xpath("//label[text()='First Name']/following-sibling::d ...

The issue with Spring Boot on Heroku is that it fails to log incoming requests

While developing my Nuxt App front-end and Spring Boot API, everything functioned perfectly in my local environment. However, once I deployed both applications to Heroku, I encountered an issue where certain URLs were returning 404 error pages. Upon examin ...

Troubleshooting a setTimeout filter problem in Vue

Implementing a notification system in Vue has been my latest project. I've created a Notifications component to store error messages that I want to display. data(){ return { alerts: { error: [] } ...

Calculating the v-model name dynamically within a v-for loop

I am currently working on a form that is dynamically generated with a v-for loop. Important Note: I am utilizing "@" to escape blade in this process. My Vue instance includes the following data: data: { form: { inputs: [{icon: "", name="", ...

Troubleshooting a CSS problem on a table filled with images - See attached screenshots for

I've been working on a project involving my phpmyadmin database generating a series of 6 images on my website. I've placed them in a table, but now I'm facing some challenges - even though it seemed simple at first! The goal is to display t ...

Adjust the size of the font based on the screen resolution

What is the best way to adjust font size based on screen resolution so that text remains as a single line when the screen is small? For example: http://prntscr.com/2qa9ze <div class="centerbreaking"> <section id="breaking-news"> <div id ...

Vue.JS component containing DOM elements outside of the designated $el scope

Transitioning from a custom front-end framework to Vue is a new adventure for me. Our website is gradually integrating Vue, and as we refactor old components, I've encountered an issue. My question is: Can a component create DOM elements outside of i ...

The Vue warning states that the property "$store" was attempted to be accessed during rendering, but it is not defined on the current instance

Hello, I am new to the world of web development and currently working on an online shop project. I have encountered two errors that I'm struggling to fix: 1) [Vue warn]: Property "$store" was accessed during render but is not defined on instance. 2) ...

Having trouble with the alignment of items in Vue?

Currently, I am using the Vue framework in combination with Vuetify library to develop a web page. The main issue I am facing is related to card alignment on the page. When there are only a few cards displayed, the alignment looks perfect but if the number ...

Step by step guide to showcasing images dynamically in user interface

My current project involves displaying a screen with an HTML table and an image. The HTML table is fully dynamic. The Code Working Process When the user loads a page (with a URL), I render an HTML table in different parts as the page loads. I retrieve al ...

php Use cURL and the DOM to extract content with specified CSS styling

Unclear in the title, I want to copy all content from a specific div on an existing webpage (not owned by me). The code successfully extracts the content. Extractor code: // Get Data $curl_handle=curl_init(); curl_setopt($c ...

Include previous input as a "phantom" thumbnail to the slider element of type "range"

https://i.stack.imgur.com/JnuCN.png Using a tutorial from w3schools, I have customized a regular range slider. The objective is to send a new value command to an external MQTT-based home automation system and display the previous value as a ghost-thumb in ...

How can a loading indicator be displayed while retrieving data from the database using a prop in a tabulator?

Incorporating a tabulator component into my vue app, I have set up the Tabulator options data and columns to be passed via props like this: // parent component <template> <div> <Tabulator :table-data="materialsData" :ta ...

Truncating decimal points in JavaScript

In this scenario, if the number after the decimal point is 0, then the zero should be removed. Otherwise, the number should be displayed as it is. Here are some examples of what I am aiming for in vue: 100.023 => 100.023 1230.0 => 1230 ...

Is it possible to enable sorting for every column in the b-table component?

After reviewing the information on sorting per column in the bootstrap-vue documentation, I am curious if it is possible to enable sorting for the entire table. ...

Vuetify: Responsive v-date-picker width for v-dialog and v-menu

I am looking to create an adaptive date picker using v-date-picker. When the page is viewed on a phone, I want the date picker to open in a v-dialog, and when viewed on a desktop, I want it to open in a v-menu. Here is my attempt: <template> < ...