How to specify a custom name of build files project in VueJs

I have a small problem with cache in production files Mb someone know how i can specify custom name for js and css file in dist as like chunk-24545415.js?v=232315 Or b someone know some guide about this

Upvotes: 2

Views: 1510

Answers (1)

Shoejep
Shoejep

Reputation: 4839

Take a look at Code Splitting and Magic Comments documentation.

In your webpack.config.js you can specify a format for the chunk filename.

module.exports = {
  //...
  output: {
    //...
    chunkFilename: '[id].js'
  }
};

Sadly, if you want a custom name for each chunk, the best solution I've found for Webpack is to use the Magic Comments.

Basically when you do an import, you put a special comment, specifying the name of the chunk.

 import(/* webpackChunkName: 'my-first-chunk' */ "./my-first-chunk.vue")

You also need to use [name] in the chunkFilename if you want to use magic comments.

chunkFilename: '[name].js'

Upvotes: 3

Related Questions