Search code examples
vue.jswebpackvue-cli

Giving static filenames for build files in vue-cli3


I am using vue-cli3, when i build using npm run build -- --mode=production, it gives 2 css files and 2 js files.

Everytime i make a code change the name of the file also changes like app.de90cdf7.js and chunk-vendors.a9204242.js.

Is there a way in vue-cli to hardcode the files names as app.js and chunk-vendors.js ?


Solution

  • I'm little late to the party. We can chain webpack to apply name changes. Using version @vue/cli 5.0.4 in year 2022

    const { defineConfig } = require("@vue/cli-service");
    module.exports = defineConfig({
      transpileDependencies: true,
      chainWebpack : (config) => {
        config.output.filename('[name].js');
      },
      css: {
        extract: {
          filename: '[name].css',
          chunkFilename: '[name].css'
        }
      }
    });
    
    

    enter image description here