1.0.4 • Published 4 years ago

@frontended/axios-loader v1.0.4

Weekly downloads
5
License
ISC
Repository
github
Last release
4 years ago

frontended

    1. 给前端开发同学更方便的后台能力,让调用后台代码像 import 后调用函数一样简单
    1. 具备生成代码的能力,可以自动生成微服务甚至serverless

使用

backend/add.js

export async function add({ x, y }) {
  return x + y
}

src/app.js

import { add } from '../backend/add'
  ;
(async () => document.write(await add({ x: 1, y: 2 })))()

webpack.config.js

var HtmlWebpackPlugin = require('html-webpack-plugin')
var path = require('path')

module.exports = {
  entry: "./src/app.js",
  output: {
    path: path.resolve(__dirname, './dist'),
    filename: 'bundle.[hash].js'
  },
  module: {
    rules: [
      {
        test: /backend[\/|\\]frontended[\/|\\].*\.js$/,
        use: {
          loader: 'frontended/axios-loader',
          options: {
            apiPrefix: '/api',
            backendFolder: 'backend/frontended'
          }
        }
      }
    ]
  },
  plugins: [new HtmlWebpackPlugin()],
}

然后构建

yarn webpack

然后启动

frontended-express-runner
1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.0

4 years ago