- Create a file in your root of project
vue.config.js
I am using few other options too but your needed one is this.
const path = require('path');
module.exports = {
lintOnSave: true,
filenameHashing: false,
chainWebpack: config => {
config.optimization.delete('splitChunks')
}
};
This will delete the chunks created and will let you use only single file of CSS
as well as JS
.
filenameHashing: false
this part will remove the hashing on files.
config.optimization.delete('splitChunks')
this will remove chunks.
More specifically with your requirement.
Use these configurations
module.exports = {
lintOnSave: true,
filenameHashing: false,
configureWebpack: {
optimization: {
cacheGroups: {
default: false,
// Merge all the CSS into one file
styles: {
name: 'styles',
test: /\.s?css$/,
chunks: 'all',
minChunks: 1,
reuseExistingChunk: true,
enforce: true,
},
},
}
}
};
Through this way, your JS code will be split into chunks but CSS File will be merged all in one.
More if you want to configure your JS chunks as well you can use these settings.
module.exports = {
lintOnSave: true,
filenameHashing: false,
configureWebpack:{
optimization: {
cacheGroups: {
default: false,
// Custom common chunk
bundle: {
name: 'commons',
chunks: 'all',
minChunks: 3,
reuseExistingChunk: false,
},
// Customer vendor
vendors: {
chunks: 'initial',
name: 'vendors',
test: 'vendors',
},
// Merge all the CSS into one file
styles: {
name: 'styles',
test: /\.s?css$/,
chunks: 'all',
minChunks: 1,
reuseExistingChunk: true,
enforce: true,
},
},
}
}
};