question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Vue plugin breaks when using UglifyJS Webpack plugin

See original GitHub issue

Been trying to track down a rather annoying little issue and have not had much luck, hoping there may be some insight on how to fix this.

The problem I’m running into is that when running my Webpack dev config, everything runs fine and all the checks in the app work with the given abilities. However, when running through a production build, I found that checking against model instances did not work as it did when running the webpack-dev-server and the dev conf. (However, checking against model names works)

Works in dev + prod builds:

$can('read', 'users')

Works in dev but not in production build:

$can('read', user)

After a lot of troubleshooting, If found that when commenting out the uglify webpack config in webpack.prod.conf.js, everything works again.

Here’s the uglify block in question

{
  plugins: [
    new UglifyJsPlugin({
      uglifyOptions: {
        compress: {
          warnings: false
        }
      },
      sourceMap: config.build.productionSourceMap, // evaluates to true
      parallel: true
    }),
    // ... more plugins
  ]
}

I have tried using the exclude option but no luck there. Any idea what might be causing this and how it could be fixed? I know uglifyjs-webpack-plugin is used in a lot of projects, so hoping that this may help someone else as well.

Probably also worth mentioning that I haven’t had any issues with any other dependencies (of which there are a lot, very large project).

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
Olena-Stotskacommented, Apr 8, 2019

Do you use ES6 classes (or constructor functions) for your models?

If so, look at https://stalniy.github.io/casl/abilities/2017/07/21/check-abilities.html#instance-checks (there is an Important section below the 2nd paragraph about minification)

0reactions
stalniycommented, Apr 10, 2019

Cool! You are welcome 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

MiniCssExtractPlugin
webpack is a module bundler. Its main purpose is to bundle JavaScript files for usage in a browser, yet it is also capable...
Read more >
Vuejs App works in dev breaks in production -- build errors
My Vuejs app runs successfully in dev localhost but once I run the ... -css-assets-webpack-plugin/node_modules/postcss/lib/input.js:130:16) ...
Read more >
Configuring Webpack - Vue Styleguidist
Note: CommonsChunkPlugins , HtmlWebpackPlugin , UglifyJsPlugin ... Warning: You are likely to break Vue styleguidist using these options, if you are not ...
Read more >
Untitled
I decided to use Rollup (with rollup-plugin-vue) for single-file Vue components. ... These will be bundled and minified into two Minify files with...
Read more >
Decrease front-end size - web.dev
In webpack 3, the UglifyJS plugin can't compile the ES2015+ (ES6+) code. This means that if your code uses classes, arrow functions or...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found