vuejs-templates / webpack

A full-featured Webpack + vue-loader setup with hot reload, linting, testing & css extraction.
MIT License
9.7k stars 4.39k forks source link

Uglify error when build #978

Closed hackuun closed 6 years ago

hackuun commented 6 years ago

Hello. I got an error with one of the packages vue-particles when building the project. It's because it's using ES6 syntax I guess. I can't find the answer how to solve it. I even doesn't see where Uglify comes from in webpack template, I see no related plugins.

ERROR in static/js/vendor.65207c1cf20abf7ff70e.js from UglifyJs
Unexpected token: punc (() [./~/vue-particles/src/vue-particles/index.js:6,0][static/js/vendor.65207c1cf20abf7ff70e.js:33623,12]

Can somebody help?

LinusBorg commented 6 years ago

I even doesn't see where Uglify comes from in webpack template, I see no related plugins.

That would be here

I can't find the answer how to solve it.

You already commented two different closed issues where solutions were provided. You have to adjust the babel-loader's include paths here so that the source will be transpiled to ES5

hackuun commented 6 years ago

@LinusBorg cool, but if I add resolve('node_modules/menu-aim') then I got other kind of Error

ERROR in ./~/menu-aim/src/index.js
Module build failed: Error: Couldn't find preset "es2015" relative to directory "/home/***/Documents/WORK/EXAMPLES/vue-examples/node_modules/menu-aim"
LinusBorg commented 6 years ago

Babel-loader finds the .babelrc file in that packages folder and tries to use its settings for transpilation, but that package is not installed because the webapck template uses a different one.

Sidenote: The menu-aim package wasn't the one producing the errror, was it? That package appears to provide an ES5 build (it has a .babelrc file with the es2015 preset, after all...).

But: Your OP seems to indicate that vue-particles is the problem, so you should include resolve('node_modules/vue-particles'). As this package has no babel config, you won't have a conflict of configs like you have with that menu-aim package.

Edit: I just saw that I already cam across this package before: https://github.com/creotip/vue-particles/issues/7#issuecomment-330031021

The best solution would be if the author of the package simply ran npm run build and changed the main file of the package to the built file instead of the source.

hackuun commented 6 years ago

@LinusBorg I had errors with both of this packages. It worked with vue-particles, but menu-aim throws this error.

LinusBorg commented 6 years ago

Well, then that seems to be a problem of that package - its code isa ppearantly not completely transpiled to ES5, even though it appears it should.

hackuun commented 6 years ago

Thanks, @LinusBorg

ddiegommachado commented 5 years ago

How to solve it? Someone? I have same problem!