jasonboy / koa-web-kit Goto Github PK
View Code? Open in Web Editor NEW🚀A Modern, Production-Ready, and Full-Stack Node Web Framework with React
License: MIT License
🚀A Modern, Production-Ready, and Full-Stack Node Web Framework with React
License: MIT License
请问,在chrome浏览器提示的错误,访问http://localhost:3000/serviceWorker.js报错,
报错内容:
The script has an unsupported MIME type ('text/html').
Failed to load resource: net::ERR_INSECURE_RESPONSE
replace deploy.sh
with js script for cross-platform compatiblity
在使用代理时,我本地有一些运行出问题,进行了下面的修改,烦请确认:
1.在routes/proxy.js
中,修改
const apiProxy = new HttpClient({ endPoint, prefix });
为
const apiProxy = new HttpClient({ endPoint: endPoint, prefix: prefix });
2.services/HttpClient.js
方法 _finalizeRequestOptions
修改如下
`_finalizeRequestOptions(options = {}) {
let optionPrefix = options.prefix || this.options.prefix;
// TODO: a path rewrite could be better
if (isCustomAPIPrefix && optionPrefix) {
let optionEndPoint = options.endPoint || this.options.endPoint;
let endPointUrl = new URL(optionEndPoint);
options.headers.host = endPointUrl.host;
options.url = options.url.replace(new RegExp(`^${optionPrefix}`), '');
}
return options;
}`
(node:58220) UnhandledPromiseRejectionWarning: TypeError: res.getHeader is not a function
at processRequest (/Users/blockmood/Desktop/pc/node_modules/webpack-dev-middleware/lib/middleware.js:82:18)
at ready (/Users/blockmood/Desktop/pc/node_modules/webpack-dev-middleware/lib/util.js:51:12)
at handleRequest (/Users/blockmood/Desktop/pc/node_modules/webpack-dev-middleware/lib/util.js:167:5)
at Promise (/Users/blockmood/Desktop/pc/node_modules/webpack-dev-middleware/lib/middleware.js:44:7)
at new Promise (<anonymous>)
at middleware (/Users/blockmood/Desktop/pc/node_modules/webpack-dev-middleware/lib/middleware.js:43:12)
at Promise (/Users/blockmood/Desktop/pc/node_modules/koa-webpack/lib/middleware.js:28:9)
at new Promise (<anonymous>)
at /Users/blockmood/Desktop/pc/node_modules/koa-webpack/lib/middleware.js:27:20
at dispatch (/Users/blockmood/Desktop/pc/node_modules/koa/node_modules/koa-compose/index.js:42:32)
at createGenerator (/Users/blockmood/Desktop/pc/node_modules/koa-convert/index.js:24:16)
at createGenerator.next (<anonymous>)
at Object.<anonymous> (/Users/blockmood/Desktop/pc/node_modules/koa-history-api-fallback/lib/index.js:104:5)
at Generator.next (<anonymous>)
at onFulfilled (/Users/blockmood/Desktop/pc/node_modules/co/index.js:65:19)
at /Users/blockmood/Desktop/pc/node_modules/co/index.js:54:5
(node:58220) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:58220) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
winston is kind of slower than some new json logger, the new logger pino is much more lightweight and faster, it's a good start to use pino
the current Dockerfile is just some kine of demo, which is not production ready.
TODO:
是否需要新开的entry 来处理路由,,,,,还是说在路由内部配置404 component
Refused to execute script from 'https://xx.com/static/13-124.chunk.js' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled
动态加载页面,控制台会出现 这个问题,为什么会出现这个问题?
偶发的
您好
再问个问题,如果想要服务器渲染(ssr)的方式运行,应执行什么命令?
我运行了npm run deploy后,查看源码还是JS进行页面渲染的。
$ npm run dev:ssr
[email protected] dev:ssr /myhome/koa-web-kit-2.8.2
cross-env ENABLE_HMR=0 CSS_MODULES=0 ENABLE_SSR=1 npm-run-all -p watch watch:ssr start
[email protected] watch /myhome/koa-web-kit-2.8.2
webpack --watch --progress --hide-modules --config config/webpack.config.dev.js
[email protected] watch:ssr /myhome/koa-web-kit-2.8.2
npm run ssr -- --watch
[email protected] start /myhome/koa-web-kit-2.8.2
nodemon --trace-warnings server.js
[email protected] ssr /myhome/koa-web-kit-2.8.2
webpack --progress --config config/webpack.config.ssr.js "--watch"
[nodemon] 1.18.10
[nodemon] to restart at any time, enter rs
[nodemon] watching: /myhome/koa-web-kit-2.8.2/api//* /myhome/koa-web-kit-2.8.2/config//* /myhome/koa-web-kit-2.8.2/build/node//* /myhome/koa-web-kit-2.8.2/routes//* /myhome/koa-web-kit-2.8.2/utils//* /myhome/koa-web-kit-2.8.2/services//* app-config.js server.js
[nodemon] starting node --trace-warnings server.js
Using [/myhome/koa-web-kit-2.8.2/config/app-config.js] as basic app configuration
Using [/myhome/koa-web-kit-2.8.2/config/app-config.js] as basic app configuration
Using [/myhome/koa-web-kit-2.8.2/config/app-config.js] as basic app configuration
10% building 0/0 modules 0 active
webpack is watching the files…
(node:56855) DeprecationWarning: Tapable.plugin is deprecated. Use new API on .hooks
instead
10% building 0/0 modules 0 active
webpack is watching the files…
10% building 0/1 modules 1 active ...ctjs/ 10% building 0/1 modules 1 active .../reactjs/koa-web-kit-2.8.2 15% building 43/73 modules 30 active ...ages/School/schoolInfo/stuPlan/index.js/myhome/koa-web-kit-2.8.2/node_modules/antd/dist/antd.css:15
body {
^
SyntaxError: Unexpected token {
at new Script (vm.js:83:7)
at createScript (vm.js:267:10)
at Object.runInThisContext (vm.js:319:10)
at Module._compile (internal/modules/cjs/loader.js:684:28)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:732:10)
at Module.load (internal/modules/cjs/loader.js:620:32)
at tryModuleLoad (internal/modules/cjs/loader.js:560:12)
at Function.Module._load (internal/modules/cjs/loader.js:552:3)
at Module.require (internal/modules/cjs/loader.js:657:17)
at require (internal/modules/cjs/helpers.js:22:18)
15% building 47/73 modules 26 active ...ages/School/schoolInfo/stuPlan/index.js[nodemon] app crashed - waiting for file changes before starting...
15% building 47/90 modules 43 active .../pages/School/schoolInfo/yishu/index.js 19% building 82/111 module 16% building 50/103 modules 53 active ....2/node_modules/redux-thunk/es/index.js 20% building 85/111 modul 19% building 81/117 modules 36 active ...modules/core-js/modules/_regexp-exec.js 20% building 91/144 modul 34% building 200/234 modules 34 active ...kit-2.8.2/node_modules/ 71% after chunk graph WebAssemblyModules 34% building 201/234 modules 33 active ...kit-2.8.2/node_modules/antd/es/index.js 87% record chunks Record 34% building 204/234 modules 30 active ...kit-2.8.2/node_modules/antd 88% content hashing JavascriptModule 35% building 215/254 modules 39 active ...ol/schoolInfo/schoolView/viewContent.jsHash: 81441c461dd449737536
Version: webpack 4.28.4
Time: 2705ms
Built at: 2019/02/20 下午5:41:32
Asset Size Chunks Chunk Names
ssr.js 2.56 MiB ssr [emitted] ssr
Entrypoint ssr = ssr.js
[./build/app/manifest.json] 368 bytes {ssr} [built]
[./build/react-loadable.json] 1.55 MiB {ssr} [built]
[./src/AppRoutes.jsx] 1.52 KiB {ssr} [built]
[./src/modules/context.js] 360 bytes {ssr} [built]
[./src/pages/routes.js] 10 KiB {ssr} [built]
[./src/ssr/index.js] 5.14 KiB {ssr} [built]
[@babel/runtime/helpers/interopRequireDefault] external "@babel/runtime/helpers/interopRequireDefault" 42 bytes {ssr} [built]
[@loadable/component] external "@loadable/component" 42 bytes {ssr} [built]
[core-js/modules/web.dom.iterable] external "core-js/modules/web.dom.iterable" 42 bytes {ssr} [built]
[prop-types] external "prop-types" 42 bytes {ssr} [built]
[react] external "react" 42 bytes {ssr} [built]
[react-dom/server] external "react-dom/server" 42 bytes {ssr} [built]
[react-loadable] external "react-loadable" 42 bytes {ssr} [built]
[react-loadable/webpack] external "react-loadable/webpack" 42 bytes {ssr} [built]
[react-router-dom] external "react-router-dom" 42 bytes {ssr} [built]
+ 203 hidden modules
36% building 218/258 modules 40 active ...-2.8.2/src/components/ziliao/index.scss[nodemon] restarting due to changes...
[nodemon] starting node --trace-warnings server.js
38% building 239/282 modules 43 active ...-2.8.2/src/components/Footer/index.scssUsing [/myhome/koa-web-kit-2.8.2/config/app-config.js] as basic app configuration
68% building 591/604 modules 13 active ...2/node_modules/zrender/lib/core/util.js/myhome/koa-web-kit-2.8.2/node_modules/antd/dist/antd.css:15
body {
^
SyntaxError: Unexpected token {
at new Script (vm.js:83:7)
at createScript (vm.js:267:10)
at Object.runInThisContext (vm.js:319:10)
at Module._compile (internal/modules/cjs/loader.js:684:28)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:732:10)
at Module.load (internal/modules/cjs/loader.js:620:32)
at tryModuleLoad (internal/modules/cjs/loader.js:560:12)
at Function.Module._load (internal/modules/cjs/loader.js:552:3)
at Module.require (internal/modules/cjs/loader.js:657:17)
at require (internal/modules/cjs/helpers.js:22:18)
[nodemon] app crashed - waiting for file changes before starting...nearGradient.js
95% emitting ManifestPlugin(node:56855) DeprecationWarning: Chunk.forEachModule: Use for(const module of chunk.modulesIterable) instead
Hash: aa624165a41dea2ef279
Version: webpack 4.28.4
Time: 10269ms
Built at: 2019/02/20 下午5:41:39
Asset Size Chunks Chunk Names
app.css 661 KiB app [emitted] app
app.css.map 814 KiB app [emitted] app
app.js 11.3 MiB app [emitted] app
app.js.map 11.1 MiB app [emitted] app
assets/static/favicon.ico 16.6 KiB [emitted]
assets/static/logo.svg 2.61 KiB [emitted]
favicon.ico 16.6 KiB [emitted]
index-backup.html 1.16 KiB [emitted]
manifest.json 368 bytes [emitted]
runtime.js 6.08 KiB runtime [emitted] runtime
runtime.js.map 5.98 KiB runtime [emitted] runtime
Entrypoint app = runtime.js runtime.js.map app.css app.js app.css.map app.js.map
ERROR in ./src/App.jsx
Module not found: Error: Can't resolve 'react-addons-css-transition-group' in '/myhome/koa-web-kit-2.8.2/src'
@ ./src/App.jsx 16:60-104
@ ./src/index.js
Hash: 40799cda9bbd9526a833
Version: webpack 4.28.4
Time: 109ms
Built at: 2019/02/20 下午5:41:40
Asset Size Chunks Chunk Names
ssr.js 2.56 MiB ssr [emitted] ssr
Entrypoint ssr = ssr.js
[./build/react-loadable.json] 1.55 MiB {ssr} [built]
+ 217 hidden modules
[nodemon] restarting due to changes...
[nodemon] starting node --trace-warnings server.js
Using [/myhome/koa-web-kit-2.8.2/config/app-config.js] as basic app configuration
/myhome/koa-web-kit-2.8.2/node_modules/antd/dist/antd.css:15
body {
^
SyntaxError: Unexpected token {
at new Script (vm.js:83:7)
at createScript (vm.js:267:10)
at Object.runInThisContext (vm.js:319:10)
at Module._compile (internal/modules/cjs/loader.js:684:28)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:732:10)
at Module.load (internal/modules/cjs/loader.js:620:32)
at tryModuleLoad (internal/modules/cjs/loader.js:560:12)
at Function.Module._load (internal/modules/cjs/loader.js:552:3)
at Module.require (internal/modules/cjs/loader.js:657:17)
at require (internal/modules/cjs/helpers.js:22:18)
[nodemon] app crashed - waiting for file changes before starting...
大概的问题就是 es6 class 语法没有编译,导致ie11 以下无法识别。
请问下,webpack.config.node.js的作用是将koa的代码压缩打包么? 如何是压缩打包,那压缩打包后,是直接启动打包后的文件么?
pages
dir for all page level react componentspages
dir structure, just like next.js did场景:
正式线 有两台服务器
线上两个版本代码共存在build目录,当时因为为了防止cdn缓存
出现情况:
刷新页面,有时候访问旧版js,有时候访问新版js
请问 服务器端渲染这块怎么判断要加载哪个js的? 为什么会出现这个情况?
这套代码有配置好开发的dev环境吗,好像yarn dev后不会监听文件的变化重新打包
request is kind of bloated, to make the project more lightweight, got is a good replacement, which is promise based by defualt
假设 http://localhost:3000/api 可能转发的时候成了 http://www.xx.com//api || http://www.xx.com/api//... ,请问这种时候问题在哪里可以排查出来?
add support for using dotenv to pass app configurations, also should be compatible with legacy app-config.js
API_ENDPOINTS
can accept simple url string, so it can be better compatiable with dotenv有时候会报错 怎么去掉这个报错?
socket.js:19 WebSocket connection to 'ws://localhost:63065/' failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED
Hi, I just came from your blog React Server Side Rendering with Koa Part II.
What you described is excited, but as I try to adjust it to my own project, I found the Scaffolding is difficult to use with so many configurations.
Could you please offer a small project that targets the core feature and leaves the wrapper function for further reference.
Could add a cli tool to generate the project skeleton
就是他会单独把组件里面的css 也单独拆分出来 导致页面的css有些位置错乱
use styled-components as the main style solution, use tailwindcss for css utlities, sass may be unnecessary now
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.