I use Vue-CLI to build my vue.js project.
When I use lighthouse, I see big opportunities of performance: "Preload Key requests" with these warnings:
crossorigin
attribute properly.crossorigin
attribute properly.crossorigin
attribute properly.crossorigin
attribute properly.Does anyone have a solution to fix it with Vue-CLI and vue.config.js to modify the webpack config?
And can you explain the problem?
You should be able to configure crossOriginLoading in webpack config file.
module.exports = {
//...
output: {
crossOriginLoading: 'anonymous'
}
};
Not sure if you have a separate webpack config file or not, but if you are using default vue.config.js file, you can use configureWebpack
option for the same:
module.exports = {
configureWebpack: {
output: {
crossOriginLoading: 'anonymous'
},
...
}
}
I've used preload-webpack-plugin ( https://www.npmjs.com/package/preload-webpack-plugin )
const PreloadWebpackPlugin = require('preload-webpack-plugin');
// adds <style> tag with preload
module.exports = {
...,
plugins: [
...,
new PreloadWebpackPlugin({
rel: 'preload',
as: 'style',
include: ['main', 'profile', 'search'], // can be 'allChunks' or 'initial' or see more on npm page
fileBlacklist: [/\.map|.js/], // here may be chunks that you don't want to have preloaded
})
]
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.