1.0.4 • Published 3 years ago

koa-web-webpack v1.0.4

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

使用说明

  • 使用基本步骤请参考: koa-web
  • 支持vue-loader语句

安装 koa-web-webpack

npm i koa-web
npm i koa-web-webpack

启动程序

const Koa = require("koa");
const KoaWeb = require('koa-web');
const KoaWebWebPack = require('koa-web-webpack');

const app = new Koa();

KoaWeb(KoaWebWebPack);

app.use(KoaWeb({
  path: __dirname,
  
  // webpack调试模式, 默认为true
  webpackDebug: false
}));

app.listen(3000, () => {
  console.log("server is running at http://localhost:3000");
});

webpack调用实例

创建html页面: /html/webpack.html

<!DOCTYPE html>
<html lang="en">
<head></head>
<body>
  <script src="./webpack.js"></script>
</body>
</html>

创建vue模块: /html/webpack.vue

<template>
  <div class="mytest">
    <div @click="inc++">点击: {{inc}}</div>
    <div class="in">
      Hello Vue!
    </div>
  </div>
</template>

<script>
export default {
    data(){
        return {
            inc: 0
        }
    }
}
</script>

<style lang="scss" scoped>
  .mytest {
    color:#080;
    .in {
      color: #F33;
    }
  }
</style>

<style>
  .other {
    color:#FF0;
  }
</style>