My vue application, compiled using vue-cli, has a vue.config.js file structured as follows:
'use strict';
module.exports = {
publicPath: `${process.env.CDN_URL || ''}/dist/`,
lintOnSave: true,
transpileDependencies: [],
outputDir: '.tmp/dist',
pages: {
navigator: {
entry: 'vue/home/main.ts',
template: 'views/home/index.ejs',
// Will output to dist/views/home/index.ejs
filename: 'views/home/index.ejs',
},
},
chainWebpack(config) {
config.module
.rule('ejs')
.test(/\.ejs$/)
.use('html')
.loader('html-loader');
},
};
I want webpack to include
nonce="<%= nonce %>"
for each generated script tag. I have tried setting the __webpack_nonce__
variable in various sections of vue.config.js without success. Attempts include adding it to chainWebpack() and configWebpack(), as well as placing it in vue/home/main.ts file. None of these approaches have yielded the desired result. How can I successfully add nonce attributes to the script tags?
The specific versions being used are vue 2.6.x and vue cli 4.5.x