koa-babel-webpack-boilerplate

授权协议 Readme
开发语言 JavaScript
所属分类 Web应用开发、 常用JavaScript包
软件类型 开源软件
地区 不详
投 递 者 艾谦
操作系统 跨平台
开源组织
适用人群 未知
 软件概览

koa-babel-webpack-boilerplate

A simple boilerplate to create REST apps with

  • koa@next (currently 2.0.0-alpha.3)
  • babel (for async, await and stage-2 support)
  • webpack

How to use

Boilerplate is packed with koa-router@next in order to have a routing system.

Install development dependencies

npm i

Create a route

router.get('/:id', async (ctx) => {
  ctx.body = await database.get(ctx.params.id);
  // Feel the awesomeness
});

Run development

npm run development

Build

npm run build

Run the built version

node bin/server.bundle.js
// or
npm run run

Distribute and run the built file

npm i --production // to avoid dev dependencies
npm run run

### Exceptions

This boilerplate contains a simple HTTP exception system in order to demonstrate how to deal with exceptions in koa. See exceptions.js.


Why webpack/babel ?

babel-node is not recommended for production. While node doesn't support natively async/await, we need to transpile the code with babel. Webpack is not necessary in this boilerplate but having the server built in a single file is pretty awesome though.

License

MIT

 相关资料
  • koa-webpack-middleware webpack-dev-middleware for koa2 with HMR(hot module replacement) supports. Install $ npm i koa-webpack-middleware -D Depends This middleware designd for koa2 ecosystem, make sur

  • webpack-babel-env-deps Find dependencies to transpile with Babel. �� Read the docs! A webpack helper to find dependencies of your project that require transpilation with Babel (and @babel/preset-env)b

  • babel-plugin-webpack-alias This Babel 6 plugin allows you to use webpack aliases and most of webpack resolve features in Babel. This plugin is simply going to take the aliases defined in your webpack

  • Tree-shaking example with Babel and Webpack This repository shows how to configure Babel and Webpack to enable tree-shaking.It will eliminate dead code if they have ES2015 module format. The source co

  • DEPREACTED due to lack of support/bug fixes/ new features, project abandoned, please migrate on https://github.com/webpack-contrib/terser-webpack-plugin Babel Minify Webpack Plugin A Webpack Plugin fo

  • webpack-babel-multi-target-plugin This project, inspired by Phil Walton's articleDeploying es2015 Code in Production Today,adds tooling to simplify the additional configuration with aWebpack plugin, B