Giter Club home page Giter Club logo

egg-vue-typescript-boilerplate's Introduction

egg-vue-typescript-boilerplate

基于 Egg + Vue + Webpack SSR 服务端渲染和 CSR 前端渲染工程骨架项目。

Single Page Application Isomorphic Example for Egg + Vue, Front-End and Node of The Application are Written in TypeScript.

Document

QuickStart

  • Development
$ npm install -g easywebpack-cli
$ easy init
$ npm install
$ npm run dev
$ open http://localhost:7001
  • Publish
npm run tsc
npm run build
npm start

Features

  • ✔︎ Single Page Application, Support Vue Server Side Render and Client Side Render Modes, Rendering Cache, Automatic Downgrade
  • ✔︎ Front-End and Node of The Application are Written in TypeScript, Use vue-property-decorator and vuex-class
  • ✔︎ Build with Webpack + TypeScript, Auto Building, Hot Reload, Code Splitting, High Speed, Performance Optimization

Rendering

  • Front-End TypeScript

Front-End TypeScript

  • Node TypeScript

Node TypeScript

  • UI ScreenShot

UI ScreenShot

TypeScript

License

MIT

egg-vue-typescript-boilerplate's People

Contributors

howaboutryze avatar hubcarl avatar morkro avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

egg-vue-typescript-boilerplate's Issues

构建项目出错

使用脚手架构建项目 出现如下错误:
`> egg-bin dev -r 'egg-ts-helper/register'

Error: Cannot find module ''egg-ts-helper/register''
at Function.Module._resolveFilename (module.js:536:15)
at Function.Module._load (module.js:466:25)
at Module.require (module.js:579:17)
at Function.Module._preloadModules (module.js:736:12)
at preloadModules (bootstrap_node.js:471:38)
at startup (bootstrap_node.js:184:9)
at bootstrap_node.js:608:3
⚠️ Error: D:\www\egg-vue-typescript\node_modules\egg-bin\lib\start-cluster {"typescript":true,"baseDir":"D:\www\egg
-vue-typescript","framework":"D:\www\egg-vue-typescript\node_modules\egg","workers":1} exit with code 1
⚠️ Command Error, enable DEBUG=common-bin for detail
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] dev: egg-bin dev -r 'egg-ts-helper/register'
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Raytine\AppData\Roaming\npm-cache_logs\2018-09-12T16_09_28_549Z-debug.log `

layout/admin/index.vue插入cdn后,webpack打包会卡住

在layout里面的index.vue中(app/web/component/layout/admin/index.vue)
用来显示首页的地方
<head>内试着插入cdn连结,假设polyfill.js
插入<script src="https://cdn.polyfill.io/v2/polyfill.min.js"></script>
执行npm run dev,webpack打包过程就会停住完全不动

个人猜测是把js的内容一起打包进去所以导致特别久,但不确定对不对

2019-04-17 09:13:57,774 INFO 2428 [master] node version v11.14.0
2019-04-17 09:13:57,776 INFO 2428 [master] egg version 2.21.1
2019-04-17 09:14:03,577 INFO 2428 [master] agent_worker#1:9892 started (5544ms)
2019-04-17 09:14:07,843 INFO 2428 [master] egg started on http://127.0.0.1:7001 (10067ms)
webpack build [==========                                                                                          ] 10% (0.0 seconds)
 [webpack-tool] start webpack node building server: http://127.0.0.1:9001
webpack build [==========                                                                                          ] 10% (0.0 seconds)
 [webpack-tool] start webpack web building server: http://127.0.0.1:9000
webpack build [=============                                                                                       ] 13% (2.9 seconds)

自己试过的方向:

  1. 放置不理会,看看最终有无打包好,放了近1小时仍没反应
  2. 插入别的js(如jquery, bootstrap),照卡,只是停的%数不同。也就是只要有插入一个js的cdn就会卡住
  3. 换作业系统,在MacOS、Windows 下都一样
  4. 翻过不少webpack的文件,找不到解决方向
  5. 执行npm cache clean --force,一样无效
  6. 重新安装所有套件,无用

PS: 有使用npm-check-updates把所有套件都更新到最新,且使用目前最新版本的Node.Js

先谢谢协助了

webpack 5

Hello easy-team,

I really like your tools!

I tried upgrading this example to webpack 5 by upgrading the following dependencies:

"easywebpack-cli": "^5.0.0"
"easywebpack-vue": "^5.0.1"
"egg-webpack": "^5.0.1"

However it does not work ... the generated browser code is not executable.

Could you give it a try?

Miguel

在Vue文件中使用Typescript的语法报错

app/web/page/app/app.vue里面增加了一句const a:string = 'a',编译报错

image

ERROR in ./app/web/page/app/app.vue (./node_modules/babel-loader/lib!./node_modules/vue-loader/lib/selector.js?type=script&index=0!./app/web/page/app/app.vue)
    Module build failed (from ./node_modules/babel-loader/lib/index.js):
    SyntaxError: Unexpected token (18:7)
    
      16 | sync(store, router);
      17 | 
    > 18 | const a:string = 'a'
         |        ^
      19 | 
      20 | export default {
      21 |   router,
    
     @ ./app/web/page/app/app.vue 3:0-109 3:0-109 4:0-122 17:2-16
     @ ./node_modules/babel-loader/lib!./app/web/framework/vue/entry/client-loader.ts!./app/web/page/app/app.vue
     @ multi (webpack)-hot-middleware/client?path=http://10.254.48.36:9000/__webpack_hmr&noInfo=false&reload=false&quiet=false babel-loader!./app/web/framework/vue/entry/client-loader.ts!./app/web/page/app/app.vue

/login报错

给登录页加上路由后,登录页依旧报错。
在我自己的项目里,使用renderClient也报错。
报错内容:render function or template not defined in component: anonymous

"egg-view-vue-ssr": "^3.0.5",
"egg-webpack": "^4.4.9",
"egg-webpack-vue": "^2.0.2",
"vue": "^2.5.21",
"vue-property-decorator": "^7.2.0",
"vue-router": "^3.0.2",
"vuex": "^3.0.1",
"vuex-class": "^0.3.1",
"vuex-router-sync": "^5.0.0"

renderClient 问题

这个模版能写两个最简单的demo么,我是第一次用,之前也没写过vue
在现有的模版中:

  • ctx.render('admin/home.js') 过于复杂了(这个是一个SPA?),能否再写一个单页面的。
  • ctx.renderClient('admin/login.js') 没有使用的代码,
    • 我在router定义路由访问 router.get('/login', controller.admin.login),得到的是一个仅有 layout.html 里的公共代码的空白页面
    • 新建 renderClient 渲染的页面也全是仅有 layout.html 公共代码的空白页面

弄了几天了。还是没搞定

提供的debug模式不能用

使用debug模式启动

npm run debug

结果访问对应的应用如下图所示

屏幕快照 2020-01-14 17 16 32

还有希望可以提供vscode debug的配置例子

使用`normalize.css`时服务端渲染会报错

// app/web/framework/app.ts
import 'normalize.css';
2020-03-11 17:47:29,461 ERROR 58250 [admin/home.js] server render bundle error, try client render, the server render error //egg-vue-typescript-boilerplate/node_modules/normalize.css/normalize.css:11
html {
     ^

SyntaxError: Unexpected token {
    at Module._compile (internal/modules/cjs/loader.js:721:23)
    at Module._extensions..js (internal/modules/cjs/loader.js:787:10)
    at Object.require.extensions.(anonymous function) [as .js] (/Users/funkyLover/Desktop/egg-vue-typescript-boilerplate/node_modules/ts-node/src/index.ts:431:14)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)
    at Module.require (internal/modules/cjs/loader.js:690:17)
    at require (internal/modules/cjs/helpers.js:25:18)
    at r (/Users/funkyLover/Desktop/egg-vue-typescript-boilerplate/node_modules/vue-server-renderer/build.dev.js:9310:16)
    at eval (webpack:///external_%22normalize.css%22?:1:18)
    at Object.normalize.css (__vue_ssr_bundle__:1069:1)
    at __webpack_require__ (__vue_ssr_bundle__:26:30)
    at eval (webpack:///./app/web/framework/app.ts?:6:71)
    at Module../app/web/framework/app.ts (__vue_ssr_bundle__:368:1)
    at __webpack_require__ (__vue_ssr_bundle__:26:30)
    at eval (webpack:///./app/web/page/admin/home/index.ts?:2:72)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.