nuxt: Babel transform plugin not working within NuxtJS
Hello, I’m trying to use the newly approved to Stage-1 pipeline operator in a project.
https://github.com/SuperPaintman/babel-plugin-transform-pipeline
https://github.com/babel/proposals/issues/29
I have the following
babel: {
"presets": [
"es2015",
"stage-2"
],
"plugins": [
"espower",
"transform-runtime",
"transform-pipeline"
]
}
in nuxt.config.js, .babelrc (without the “babel” key), and package.json. Yet I’m still getting “Syntax Error: Unexpected Token”
Any advise on how to get this working with Nuxt would be appreciated. I’ve tried restarting the server.
<div align="right">This question is available on Nuxt.js community (#c1596)</div>About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 34 (8 by maintainers)
I have the same issue … I don’t understand why this issue is closed while nobody can use babel plugin in nuxt …
I am having the same issue. I have included the babel spread operator in my nuxt.config:
build: { babel: { 'plugins': ['transform-object-rest-spread'] } }and I still get a compile error Unexpected Token. I too have tried using a .babelrc and I also get errors regarding the spread operator on internal nuxt files. If nuxt is using spread internally then why can’t we?
Any updates on this?
@homerjam is right about the
extend(). Just adding in the.babelrcisn’t enough, you also have to tell Webpack to use it.So first make sure your
.babelrcis set up. Then, in yournuxt.config.js:I mean if you’re using the custom server, the source codes belong to your server, such as
router,api,modeland so on, they won’t be transpiled by nuxt, because these codes are outside the nuxt.Hope you can understand my poor English, sorry for this.
The benefits of a customer is that you can make your project be a more full functionalities application. Nuxt is more involved in frontend pages and rendering. You can implement your complex backend logic (API, router, DB/Cache interaction) with custom server, it also can make you have an organized MVC architecture on the server side.
any solution for babel plugin in nuxt.config.js
@clarkdo is right, this is how I got object-spread to work:
First I made sure to install the babel plugins I needed, by running:
npm install --save-dev babel-cli babel-preset-es2015andnpm install --save-dev babel-plugin-transform-object-rest-spreadThen I added
babelto thebuildsection, specifying what presets and plugins to use, and then I addedbabel-loaderlike mentioned above:Then I also had to add the
.babelrcfile with all the same plugins specified in there.Hope this helps!