Customize Vue.js: Disable Attribute Quote Removal for Individual Pages

We have a requirement to turn off the minify.removeAttributeQuotes property for certain pages.

This is the content of my vue.config.js:

const packageJson = require('./package.json')

module.exports = {
  
  assetsDir: packageJson.name + '/static',

  chainWebpack: config => {
    config.plugins.delete('preload-search')
    config
      .plugin('html-search')
      .tap(args => {
        return [
          {
            preload: false,
            title: packageJson.description,
            template: __dirname + '/public/search.html',
            minify: {
              removeAttributeQuotes: false
            }
          }
        ]
      })
  },

  pluginOptions: {
    i18n: {
      locale: 'de',
      fallbackLocale: 'en',
      localeDir: 'locales',
      enableInSFC: true
    }
  },

  pages: {
    index: {
      entry: 'src/main.js',
      template: 'public/index.html',
      filename: 'index.html',
      title: 'Index Page',
      chunks: ['chunk-vendors', 'chunk-common', 'index']
    },
    search: {
      entry: 'src/search/main.js',
      template: 'public/search.html',
      filename: 'search.html',
      title: 'Search Page',
      chunks: ['chunk-vendors', 'chunk-common', 'search']
    }
  }

}

We are utilizing the pages property for multiple endpoints. Therefore, we need to switch from "plugin('html')" to "plugin('html-search')".

The issue at hand:

Due to our use of the pages property, the public/search.html file is not being minified, and no js/css injections are being included in the file.

All I did was:

  1. Defined the pages property following this link: https://cli.vuejs.org/config/#pages.
  2. Used webpack chaining to configure the html plugin as explained here: https://cli.vuejs.org/guide/webpack.html#modifying-options-of-a-plugin

I am out of ideas on how to solve this issue.

Regards, Mario

Answer №1

Resolved on its own by:

chainWebpack: customConfig => {
    customConfig.plugins.delete('preload-search')
    customConfig
      .plugin('html-search-plugin')
      .tap(arguments => {
        arguments[0].minify.removeAttributeQuotes = false
        return arguments
      })
}

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

The importance of variables in Express Routing

I'm really diving into the intricacies of Express.js routing concepts. Here's an example that I've been pondering over: const routes = require('./routes'); const user = require('./routes/user'); const app = express(); a ...

The customized Vaadin component with a tag is missing from the MainView layout

I am attempting to integrate my custom vis component into the MainView VerticalLayout. However, it is appearing above the layout and the layout itself contains an empty component tag. Custom component code In this section, I have labeled my component as " ...

Using JavaScript to shift an image sideways upon clicking a hyperlink on the page

One of my clients has a unique request for an image to move across the page from left to right when a link is clicked. I'm not very experienced with javascript, so I would really appreciate any guidance on how to make this happen. Thank you in advanc ...

Is it possible to bind a class using both a variable and a string?

Is there a way to include both a variable and a string as classes in a blade template? <div :class="data['type'] + ' string-class'" v-for="(data, index) in products"></div> Something similar to the example above. ...

What is the best way to rate a particular image?

while ($row = mysqli_fetch_array($result)) { echo ""; echo "<div id='img_div'>"; echo "<i class='fas fa-times'></i>"; echo "<img class='photoDeGallery' s ...

The appearance of responsive CSS is altered when deployed compared to when it is viewed on the

I'm a beginner in web development and facing an issue with my mobile CSS. The strange thing is that when I view it on localhost, everything looks great, but once deployed (tried both Heroku and GitHub), it appears distorted. Even when I make extreme c ...

Using Modal Functions in AngularJS Controller

I have been working on a project that utilizes the ui.bootstrap. As per the instructions from the tutorial I followed, my setup looks something like this: 'use strict'; angular.module('academiaUnitateApp') .controller('EntryCtr ...

Having difficulty generating a Meteor.js helper using a parse.com query

Utilizing my meteor application, I fetch and display data from Parse.com. Initially, I integrated the parse.com javascript query directly into the template's rendered function, which was successful. Now, I aim to utilize the Parse.com query in a help ...

Backing up a mongodb collection can be easily achieved with the help of express.js and Node.js

I am looking to create a monthly backup of my userdatas collection. The backup process involves: I intend to transfer the data from the userdatas collection to a designated backupuserdatas collection. A batch program should be scheduled to run automatica ...

Tips for filling in the values for the options in a select dropdown menu

Currently, I am facing a strange bug related to the select element. Whenever I open the dropdown, there is always a mysterious black option at the top. This is how my HTML looks like: This particular element is part of my test controller. <select ng- ...

A function is unable to update a global variable

I have been working on a form that allows users to set the hour, with JavaScript validation in place to ensure there is input in the form. Initially, the global variable "userInputHours" is set to 0. Within the function "validation()", when the user meets ...

Step-by-Step Guide for Uploading an Entire Folder and Its Contents

I have been working on a code to upload multiple files, but now I am facing the challenge of uploading an entire folder with multiple files and possibly subfolders containing even more files. Currently, I am utilizing JavaScript for obtaining the files and ...

Adding data from a database into an object in PHP for temporary use during the loading process can be achieved by following

I'm a beginner in PHP and I have some code that retrieves category type data from a database. I want to temporarily store this data in a PHP object while the page is loading. Initially, I need to load all predefined data and then use it when a certain ...

Present the array elements in a format that allows the user to easily choose an option and explore the content

I'm currently working on a project where users will take a Computer Based Test and be graded on a selected subject. I have a database set up with questions and multiple choice options. My goal is to display the questions in a way that allows users to ...

Tips for preserving updates following modifications in Angular 5/6?

I'm currently working on enhancing the account information page by implementing a feature that allows users to edit and save their details, such as their name. However, I am encountering an issue where the old name persists after making changes. Below ...

How can I streamline a kendo UI MVC project by eliminating unnecessary components?

After switching my MVC 5 project to utilize Kendo UI, I've noticed a significant increase in the number of files being used. Since there is no need for supporting other cultures at the moment, can I confidently delete the files within the messages an ...

Animating nested ng-repeat loops

Trying to animate a list of elements divided by rows (the parent ng-repeat) and columns (the child ng-repeat) has been quite challenging. While I was able to achieve the desired animation with individual ng-repeats, the same cannot be said for nested ng- ...

JavaScript - Imported function yields varied outcome from module

I have a utility function in my codebase that helps parse URL query parameters, and it is located within my `utils` package. Here is the code snippet for the function: export function urlQueryParamParser(params: URLSearchParams) { const output:any = {}; ...

Is there a way to hide a button on this virtual keyboard after it has been clicked?

After creating a virtual keyboard using HTML and CSS, I am looking to implement JavaScript code that will hide a button after it is clicked. Here is the code I have tried so far: function hideButton() { var button = document.getElementById("simple_butto ...

In VueJS and Quasar, what is the best way to retrieve the clicked item in order to pass it to the API?

Utilizing a codepen sample with local data, I am hoping it will work for troubleshooting purposes. However, in reality, I am using vuex and an API endpoint to source the data. Unfortunately, I cannot share the API details. The core functionality involves ...