Closed gengjiawen closed 7 years ago
Inspired by https://github.com/koajs/koa#babel-setup, but not use the same config setup.
If you're not using node v7.6+
, you can use the koa1
version(switch to koa1 branch) . However, you can set the babel config in your project if you want to run it under node v7.6
. I think it's ok for now. Thank u all the way :)
I am using node v7.6+
. But I also want to use import
and export
too.
Aha, that's a good reason. Welcome to send a pr. By the way, I want to use only one node process to run the project in dev mode, I finished it. However it's not so firendly for debugging as restarting the koa server, webpack need to rebuild files too. May be you have some ideas? If you are interested in it, you can look this comment in my blog. Thx :)
I have a solution for auto restart koa server, not sure it's you wanted. When I got time, I will send you a pr.
Ah, I also finished the auto restart. However when restarting koa server, the webpack neet to rebuild files too. I want to restart the koa server but do not rebuild files. You can send a pr any time if you got time. Thanks a lot ~! :+1:
I am using nodemon
to restart the server, which may not be as efficient as webpack.
I use it too. But you neet to run npm run dev
to start the webpack serve, and node app.js
or nodemon app.js
to start the koa serve. I finished just using node app.js
or nodemon app.js
to start both webpack & koa serve. As you can see, webpack serve is a express serve, so I can change it to koa serve. Maybe It's stupid haha :)
I don't quite follow you. Do you want to start npm run dev
and nodemon app.js
the same time ? If that is your case, you can use concurrently
.
Yep, I just use one koa serve to serve the backend api & webpack. concurrently
is a solution but not what I want. Anyway, thank u ~ :)
hi, I have a question for those changed, if I wanna use app.js
in production env, so I need compile app.js
to require version using babel ? if so, not convenience.
You don't need to compile app.js to a require version. Just using the server-entry.js is OK.
It's OK for development, but that will be a performance problem on production.
Yep, so it depends on you. However, this project is a small DEMO, try some sepecial I think that is OK~ And in the future, ES6 modules will be available in Node.js. We will see~
For production build, we may need to use change build like https://github.com/babel/example-node-server#getting-ready-for-production-use.
Is is okay to use babel for server dev, I can send a pr.