mz026 / universal-redux-template

A clean, extensible react + redux boilerplate with universal/isomorphic rendering, testing and more
464 stars 95 forks source link

[QUESTION] Deployment issue #58

Open bolicd opened 7 years ago

bolicd commented 7 years ago

Hi,

We are currently trying to deploy this boilerplate on Windows Azure AppService. Thats basically NodeJs server wrapped into iisnode module(in essence it should function the same as nodejs/express server).

When using steps for deployment, locally it works fine. However, when deployed on Azure app service we are getting the following error: (function (exports, require, module, __filename, __dirname) { import Express from 'express' ^^^^^^ SyntaxError: Unexpected token import at Object.exports.runInThisContext (vm.js:76:16) at Module._compile (module.js:542:28) at Object.Module._extensions..js (module.js:579:10)

For Azure deployment all that needs to be done is to configure web.config file which points to server.js file which should not be the cause of this issue. It seems that this is something to do with babel transpiler missing on deployment machine.

Any idea on how to solve this issue?

Thank you

mz026 commented 7 years ago

From the error message, it seems NodeJS tried to run ES6 without babel.

To run server side code without pre-built with babel (like in development), we should point the entry file to server/index.js, which require-s babel/register, instead of server/server.js.

Or, there's a task inside gulpfile building server side code with Babel. By running gulp build, it would build server side code under dist/server-build. After that we can point the entry file to the built one.

bolicd commented 7 years ago

Thanks that was one of the problems 👍

Theres some more issues when deploying on Azure, managed to solve them all now im improving procedure a bit. I'll write steps needed in case someone else tries to do the same.

Thanks

bolicd commented 6 years ago

For deployment on Azure Web App:

More info about this can be found: https://github.com/projectkudu/kudu/wiki/Custom-Deployment-Script