How can I check if a user has devtools open in my Vue 2 webapp? I am using @vue/cli 5.0.8 with the default configuration for creating and building the app.
I came across this code snippet that might work -
const minimalUserResponseInMilliseconds = 100;
const before = Date.now();
debugger;
const after = Date.now();
if (after - before > minimalUserResponseInMilliseconds) {
//Action
}
The issue I'm facing is that the default Vue build for production removes the debugger statement from the code.
Is there a way to keep this specific debugger keyword? Or prevent all debugger statements from being removed?
I attempted to add the following to my Vue.config, but the debugger statement was still stripped out
configureWebpack: {
optimization: {
minimizer: [
new TerserPlugin({
terserOptions: {
compress: {
drop_debugger: false // For checking if user opened devtools
Any assistance would be greatly appreciated, thank you!