diff --git a/.env.txt b/.env.txt new file mode 100644 index 0000000000..3ee16fb636 --- /dev/null +++ b/.env.txt @@ -0,0 +1,4 @@ +## To use this file, rename this to .env which is already ignored by git. + +## Enable console.log for your local dev environment. +VUE_APP_CONSOLE_LOG=true diff --git a/.eslintrc.js b/.eslintrc.js index c3b4297502..de478b470f 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -23,6 +23,7 @@ module.exports = { semi: ["off"], quotes: ["off"], indent: ["off"], + "no-console": 0, "jsx-a11y/click-events-have-key": "off", "padded-blocks": ["off"], "vue/singleline-html-element-content-newline": 0, diff --git a/nuxt.config.js b/nuxt.config.js index 29e66f0b42..2685d186cb 100644 --- a/nuxt.config.js +++ b/nuxt.config.js @@ -138,6 +138,15 @@ export default { config.output.publicPath = sitePrefix } }, + terser: { + // https://github.com/terser/terser#compress-options + // Exclude console.logs from prod builds. ( drop_console: true). + terserOptions: { + compress: { + drop_console: true, + }, + }, + }, }, generate: { diff --git a/plugins/axe.client.js b/plugins/axe.client.js index 4091467e77..3649c45c13 100644 --- a/plugins/axe.client.js +++ b/plugins/axe.client.js @@ -1,8 +1,16 @@ import Vue from "vue" export default function () { + const VueAxe = require("vue-axe").default + // If env file is present. + if (process.env.VUE_APP_CONSOLE_LOG) { + Vue.use(VueAxe, { + // Allow console.log on local. + allowConsoleClears: false, + }) + } + if (process.env.NODE_ENV === "development") { - const VueAxe = require("vue-axe").default Vue.use(VueAxe) } }