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.

Document how to configure `VuetifyProgressiveModule` with vue cli 3

See original GitHub issue

The default vue cli 3.x projects use the so-called “no config” webpack. It’s not clear to me (only me?) how to add VuetifyProgressiveModule to these vue cli 3.x projects.

Thank you for this library!

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:2
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
acu192commented, Mar 2, 2019

Okay, here is my vue.config.js file now (very similar to the link you posted, but some differences):

const VuetifyLoaderPlugin = require('vuetify-loader/lib/plugin');
const { VuetifyProgressiveModule } = require('vuetify-loader');

module.exports = {
  chainWebpack:  config => {
    config.module
      .rule('vue')
      .use('vue-loader')
      .loader('vue-loader')
      .tap(options => {
        options.compilerOptions.modules = [VuetifyProgressiveModule];
        return options;
      });
    const imagesRule = config.module.rule('images');
    imagesRule.uses.clear();
    config.module
      .rule('images')
        .test(/\.(png|jpe?g|gif|webp)(\?.*)?$/)
        .oneOf('progressiveImages')
          .test(/\.(png|jpe?g|gif)$/)
          .resourceQuery(/vuetify-preload/)
          .use('progressiveLoader')
            .loader('vuetify-loader/progressive-loader')
            .end()
          .use('notProgressive')
            .loader('url-loader')
            .options({ limit: 8000, fallback: { loader: 'file-loader', options: { name: 'img/[name].[hash:8].[ext]' } } })
            .end();
    config.module
      .rule('images')
        .oneOf('imagesOther')
          .merge({ loader: 'url-loader', options: { limit: 8000, fallback: { loader: 'file-loader', options: { name: 'img/[name].[hash:8].[ext]' } } } });
  },
};

After writing that file, the first build attempt it complained that there was no gm module. I was happy to see it complain, as this indicated it was trying to do something new! So, I npm install gm --save. (I have also already compiled and installed ImageMagick.)

After installing gm, it now seems to work, at first glance. I.e. It builds without error.

However, when inspecting the dist/ directory, I find that it hasn’t modified my images at all. They are identical to what is in my src/assets/ folder.

On the vue side, here is the relevant code I’m using:

<v-img :src="require('@/assets/IMG_0219.jpg?vuetify-preload')">

Any ideas for why it’s not generated progressive JPEGs?

0reactions
alexroldancommented, Apr 19, 2020

modify vue.config.js

module.exports = { transpileDependencies: ["vuetify"],

chainWebpack: (config) => {
    config.module
        .rule("vue")
        .use("vue-loader")
        .loader("vue-loader")
        .tap((options) => {
            options.transformAssetUrls = {
                "v-img": "src",
            };

            return options;
        });
    config.plugin("VuetifyLoaderPlugin").tap((args) => [
        {
            progressiveImages: true,
        },
    ]);
},

};

you should restart your server

npm run serve

Read more comments on GitHub >

github_iconTop Results From Across the Web

Configuration Reference | Vue CLI
outputDir #. Type: string. Default: 'dist'. The directory where the production build files will be generated ...
Read more >
Modes and Environment Variables - Vue CLI
Mode is an important concept in Vue CLI projects. By default, there are three modes: ... When running vue-cli-service , environment variables are ......
Read more >
Creating a Project | Vue CLI
For new projects, it is now recommended to use create-vue to scaffold Vite-based projects. Also refer to the Vue 3 Tooling Guide for...
Read more >
Vue CLI: Home
For new projects, please use create-vue to scaffold Vite-based projects. Also refer to the Vue 3 Tooling Guide for the latest recommendations.
Read more >
Working with CSS | Vue CLI
Also refer to the Vue 3 Tooling Guide for the latest recommendations. ... Sass npm install -D sass-loader sass # Less npm install...
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