I want to create a custom chunk and attach in generated index.html. I created a custom project using vue create .
and added a vue.config.js
file.
vue.config.js
module.exports = {
lintOnSave: true,
configureWebpack: {
optimization: {
splitChunks: {
cacheGroups: {
utiltest: {
name: 'utiltest',
test: /utils[\\/]test/,
priority: -30,
chunks: 'initial',
},
},
},
},
},
};
I have some util functions in src/utils/test
for which I want to create a separate bundle and attach in index.html. Like this
<script type="text/javascript" src="/js/chunk-utiltest.js"></script>
<script type="text/javascript" src="/js/chunk-vendors.js"></script>
<script type="text/javascript" src="/js/app.js"></script>
But in generated index.html file its not creating the chunk for utiltest, it has just these 2
<script type="text/javascript" src="/js/chunk-vendors.js"></script>
<script type="text/javascript" src="/js/app.js"></script>
Note: I am importing functions from utils/test in my main.js like
import testHook from '@/utils/test';
...
testHook();