You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi,
I have defined some rules for specific roles, they all are working fine. But when I build vue project in production mode, all the rules gives false. Details are here below:
I have this file ability.js, which is giving me rules:
I'm updating rules like this in App.vue (all values are valid)
this.$ability.update(getRules(role, userId))
I'm checking permissions using below code.
class ConversationView {
constructor(props) {
Object.assign(this, props)
}
}
this.$can('view', new ConversationView({ userId: Id }))
Now, when I run this code in local/development mode. It is working fine (giving me true where it needs to), but when I generate a production build it is not working as expected (always gives me false)
It’s not a CASL issue. The names of classes are minified by Vue cli (or uglify or whatever you use). So, the name in production is just a single letter. Information about type is lost then.
Hi,
I have defined some rules for specific roles, they all are working fine. But when I build vue project in production mode, all the rules gives false. Details are here below:
I have this file
ability.js
, which is giving me rules:I'm updating rules like this in App.vue (all values are valid)
I'm checking permissions using below code.
Now, when I run this code in local/development mode. It is working fine (giving me true where it needs to), but when I generate a production build it is not working as expected (always gives me false)
Development Build Command:
Development Build .env.local
Production Build Command:
Production Build .env.prod
Let me know why this is happening.
Replicated the steps here.
Follow below link to view running and expected version:

https://codesandbox.io/embed/github/s4h1u1b9h9a2m/vue-casl-example/tree/master/
Output:
Clone the same project in your local, or download from here (https://github.com/s4h1u1b9h9a2m/vue-casl-example)

After running, we're getting this output:
The text was updated successfully, but these errors were encountered: