Often with third-party packages I got such errors
ERROR in pages/menuaim.2a58f05d2d2352aae6c1.js from UglifyJs
Unexpected token: punc ()) [./node_modules/menu-aim/src/index.js:1,0][pages/menuaim.2a58f05d2d2352aae6c1.js:173,2]
Error: Webpack build exited with errors
Is there's a way to fix it? I can't find the answer. May be I need some webpack settings? Because packages itself are working fine.
Extending webpack config with this didn't help. But may be I am doing it wrong?
{
test: /\.js$/,
loader: 'babel-loader',
include: [path.join('node_modules/menu-aim')]
}
@iamdubx I can't get my head around how to implement that fix either. Maybe you can help?
No I can't help sorry, I still have no answer how to config webpack with this.
Got it. It's more webpack config than nuxt and it's pretty gnarly but here:
config.module.rules.push({
test: /\.js$/,
loader: 'babel-loader',
exclude: function(modulePath) {
return /node_modules/.test(modulePath) &&
!/node_modules\/vue-particles/.test(modulePath);
},
options: Object.assign({}, this.babelOptions)
})
getting the same problem with packages
+1
It's not releated to Nuxt source code, I'm closing the issue but you can still comment it.
@gridsystem
I tried your suggestion as well as the one on https://github.com/creotip/vue-particles/issues/7 but can't get it to work with Nuxt. Can you explain how you made it work with latest Nuxt version ?
Its works after removed bracket from filter function
Are you using Filters? On single param filter functions should have '()' on while using.
It should be like this...
<img class="save-post-icon" :src="this.postObj.is_saved | saveIcon"/>
Not like this
<img class="save-post-icon" :src="this.postObj.is_saved | saveIcon()"/>
filters.js
export function saveIcon (isSaved) {
return isSaved ? require('~/assets/post_saved.png') : require('~/assets/post_not_saved.png')
}
@gridsystem I tried add your config to nuxt.config.js, but error remains when build:
module.exports = {
head: {
title: 'demo',
meta: [
{ charset: 'utf-8' },
{ name: 'viewport', content: 'width=device-width, initial-scale=1' },
{ hid: 'description', name: 'description', content: 'Nuxt.js project' }
],
link: [
{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }
]
},
/*
** Customize the progress bar color
*/
loading: { color: '#3B8070' },
/*
** Build configuration
*/
build: {
extend (config, ctx) {
if (ctx.dev && ctx.isClient) {
config.module.rules.push({
test: /\.js$/,
loader: 'babel-loader',
exclude: function (modulePath) {
return /node_modules/.test(modulePath) &&
!/node_modules\/vue-particles/.test(modulePath)
},
options: Object.assign({}, this.babelOptions)
})
}
}
},
plugins: [
{ src: '~/plugins/particles', ssr: false }
]
}
Is there any other errors in this config file?
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Most helpful comment
Got it. It's more webpack config than nuxt and it's pretty gnarly but here: